0
我使用的代码将上传图像,将图像放在“调整大小”文件夹中,调整图像大小,将图像移动到另一个文件夹中,然后从图像中删除图像“resize”文件夹,但是我收到以下错误:PHP上传/调整图像大小时出现致命错误
“致命错误:允许内存大小33554432字节用尽(试图分配14172字节)在/ home/photogra/public_html /管理员/组件/ com_gallery /admin.gallery.php on line 649“
图像并不大! (例如,265KB)
下面是我使用的代码(与行号):
635 move_uploaded_file($_FILES['image']['tmp_name'],$mainframe->getCfg('absolute_path') ."/virtualgallery/images/resize/$newname");
636
637 /* resize images - width 600px */
638 $docRoot = $GLOBALS['mosConfig_absolute_path'];
639 $pathToImages = $docRoot.'/virtualgallery/images/resize/';
640 $pathToThumbs = $docRoot.'/virtualgallery/images/';
641 $thumbHeight = 600;
642
643 $dir = opendir($pathToImages);
644 while (false !== ($fname = readdir($dir))) {
645 $info = pathinfo($pathToImages . $fname);
646 if (strtolower($info['extension']) == 'jpg') {
647 $img = imagecreatefromjpeg("{$pathToImages}{$fname}");
648 $width = imagesx($img);
649 $height = imagesy($img);
650 $new_width = floor($width * ($thumbHeight/$height));
651 $new_height = $thumbHeight;
652 $tmp_img = imagecreatetruecolor($new_width, $new_height);
653 imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
654 imagejpeg($tmp_img, "{$pathToThumbs}{$fname}");
655 };
656 };
657 closedir($dir);
658
659 /* delete file(s) from resize folder */
660 $dir = $docRoot.'/virtualgallery/images/resize/';
661 foreach(glob($dir.'*.*') as $v) {
662 unlink($v);
663 };
此外,当我得到这个错误,图像被陷在“调整”文件夹中。如果任何人都可以提供帮助,那太棒了! :)
感谢您的帮助,至今似乎工作正常...... :) – SoulieBaby 2009-07-08 00:59:46