编辑:问题解决: 我是愚蠢的小笨蛋,我忽略了为该文件命名。 $ testSiteDir是一个没有文件名的路径。没有名字的情况下如何保存文件! D'哦! 对不起;)使用php创建缩略图图片 - 写入权限
我知道有很多类似的问题,各地,我一直在通过他们读,但因为我已经有点必须建立所有的教程和文章的混合我有一些代码,我希望工作,但没有。
我在某一点做了管理创建的图像副本到我想要使用copy()函数来移动它,工作的文件夹。但因为我想调整它,我需要使用GD(据我可以告诉)
这里是我的代码:
if (is_dir($BooksDir)) {
if ($dh = opendir($BooksDir)) {
while (($folder = readdir($dh)) !== false) {
$count++;
$exclude = array('.','..','etc.');
if (!in_array($folder, $exclude)){
echo '<div ' . ($count&1 ? 'class="oddrow"' : 'class="evenrow"') . '>';
echo $folder . "<br/>" . $count;
$subDir = $BooksDir . '/' . $folder;
$filesnfolders = scandir($subDir);
foreach ($filesnfolders as $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif') {
if ($ext == 'jpg' || $ext == 'jpeg') {
$origimg = imagecreatefromjpeg($subDir. '/' . $file);
$thHeight = 100;
$thWidth = 100;
$mainWidth = imagesx($origimg);
$mainHeight = imagesy($origimg);
$myThumbnail = imagecreatetruecolor($thWidth, $thHeight);
imagecopyresampled($myThumbnail, $origimg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
imagejpeg($myThumbnail, $testSiteDir);
}
}
}
echo '</div>';
}
}
closedir($dh);
}
}
当我尝试使用上面的我得到错误我没有写入该文件夹的权限:无法打开'C:/ xampp/htdocs/test'进行写入:权限被拒绝...
我有三本课本,读了一堆关于图片和php的文章,我还没有看到它告诉我该怎么做
发生了什么问题:)
是'C:/ xampp/htdocs/test'只读吗? – Palladium 2012-07-24 15:52:20
我试过用rightclick-> properties-> unselect readonly改变它,但这并没有改变我的区别,我也试过改变文件夹的所有者,但是这并没有帮助 – 2012-07-24 16:07:12