我一直在创建一个php脚本,它创建一个文件夹并将已发布的图像保存在创建的文件夹中,文件夹会被创建,但是我没有保存图像。
以下是剧本:
if (isset($_FILES['images'])) {
mkdir("files/test/".$new."/", 0755, true);
foreach ($_FILES['images']['tmp_name'] as $key => $value) {
if (!(empty($_FILES['images']['tmp_name'][$key]) || $_FILES['images']['tmp_name'][$key] == 'none')) {
$i_slika = 1;
$extenzion = strtolower(end(explode(".", $_FILES['images']['name'][$key])));
$file = "files/nekretnina/".$new."/".$i_slika.".".$extenzion;
while (file_exists($file)) {
$i_slika++;
$file = "files/nekretnina/".$new."/".$i_slika.".".$extenzion;
}
if (!@move_uploaded_file($_FILES['images']['tmp_name'][$key], $file)) {
$err_text = $err_text. 'Error: '.$_FILES['images']['name'][$key].'<br />';
} else {
include_once "thumbz.class.php";
$pic = new thumbz($file);
$pic->dimensionImage("resize",640);
$pic->addParam('l',0);
$pic->render($file);
}
}
}
}
答案 0 :(得分:1)
您需要使用$_FILES['images']['tmp_name'][$key]
代替$_FILES['slika']['tmp_name'][$key]
。
您的索引名称错误了!
尝试使用:
if (isset($_FILES['images'])) {
mkdir("files/test/".$new."/", 0755, true);
foreach ($_FILES['images']['tmp_name'] as $key => $value) {
if (!(empty($_FILES['images']['tmp_name'][$key]) || $_FILES['images']['tmp_name'][$key] == 'none')) {
$i_slika = 1;
$extenzion = strtolower(end(explode(".", $_FILES['images']['name'][$key])));
$file = "files/test/".$new."/".$i_slika.".".$extenzion;
while (file_exists($file)) {
$i_slika++;
$file = "files/test/".$new."/".$i_slika.".".$extenzion;
}
if (!@move_uploaded_file($_FILES['images']['tmp_name'][$key], $file)) {
$err_text = $err_text. 'Error: '.$_FILES['images']['name'][$key].'<br />';
} else {
include_once "thumbz.class.php";
$pic = new thumbz($file);
$pic->dimensionImage("resize",640);
$pic->addParam('l',0);
$pic->render($file);
}
}
}
}