我对此代码有疑问:
form.php的
$dir = date("d-m-y(H-i-s)");
mkdir('../files/'.$dir, 0755, true);
mkdir('../files/'.$dir.'/files', 0755, true);
mkdir('../files/'.$dir.'/imgs', 0755, true);
mkdir('../files/'.$dir.'/thumb', 0755, true);
//<input type="hidden" name="folder" value="<?php echo $dir ?>"/>
upload.php的
$count = 0;
$DIR = $_POST['folder'];
$imgsDIR = '../files/'.$DIR.'/imgs/';
$thumbDIR = '../files/'.$DIR.'/thumb';
foreach ($_FILES['img']['name'] as $filename)
{
$tmp = $_FILES['img']['tmp_name'][$count];
$temp = $imgsDIR.$filename;
move_uploaded_file($tmp,$temp);
make_thumb($temp ,$thumbDIR ,150);
$temp='';
$tmp='';
$count++;
}
function make_thumb($src, $dest, $desired_width) {
$source_image = imagecreatefromjpeg($src);//ok
//some cods
imagejpeg($virtual_image, $dest);//error Permission denied
}
我也试过了0644
,0777
但是没有用
我使用(完全控制)此文件夹
答案 0 :(得分:2)
调用$thumbDir
时,您需要将文件名附加到make_thumb()
,否则您将尝试存储创建的缩略图,其名称与缩略图目录相同:
foreach ($_FILES['img']['name'] as $filename) {
$tmp = $_FILES['img']['tmp_name'][$count];
$temp = $imgsDIR.$filename;
move_uploaded_file($tmp, $temp);
// make sure you have a filename and not only an directory path
make_thumb($temp, $thumbDIR.'/'.$filename, 150);
$temp='';
$tmp='';
$count++;
}