ZiBoX
Новичок
Загрузить на сервак картинку(изображение)
Господа кусок скрипта
Картинку на локале закидывает в нужный католог а вот на инетсерваке нифига! и даже никаких ошибок не выдает.
Что не так?
Господа кусок скрипта
PHP:
define("BASEDIR", dirname(__FILE__));
$path_to_file=BASEDIR."/images";
$files = $HTTP_POST_FILES['userfile'];
if (!ereg("/$", $path_to_file))
$path_to_file = $path_to_file."/";
foreach ($files['name'] as $key=>$name) {
$type = $files['type'][$key];
if (empty($type)) continue;
if ($type=="image/jpeg" || $type=="image/pjpeg"){
if ($files['size'][$key]) {
$pic_name=$name;
$location = $path_to_file.$name;
while (file_exists($location)){
$mtime=microtime();
$mtime=explode(" ",$mtime);
$mtime[0]=str_replace(".","",$mtime[0]);
$mtime=$mtime[1]-$mtime[0]-1000;
$mtime=str_replace("-","",$mtime);
$mtime=substr($mtime,0,6);
$nodub=$mtime.".jpg";
$location=str_replace(".jpg","",$location);
$location.=$nodub;
$pic_name=str_replace(".jpg","",$pic_name);
$pic_name.=$nodub;
}
$fname = $HTTP_POST_FILES['userfile']['name'][$key];
$dat = date("d,m,y");
$fp = fopen ($files['tmp_name'][$key], "rb");
$fileSize = filesize($files['tmp_name'][$key]);
$contents = fread($fp,$fileSize);
fclose($fp);
if ($fileSize<2000000){
$fp = fopen($location,"wb+");
fwrite($fp, $contents);
} else {
exit("Загружаемый файл не должен быть больше 2Мб.");
}
fclose($fp);
unlink($files['tmp_name'][$key]);
}
}else{
exit("Вы можете загрузить только картинки формата JPG/JPEG.");
}
}//[END] foreach ($files['name'] as $key=>$name)
Что не так?
