PHP 치명적인 오류로 업로드하는 동안/이미지 크기 조정
-
11-09-2019 - |
문제
내가 사용하는 코드는 이미지를 업로드한 이미지에서는"조정"폴더,이미지 크기를 조정 이미지를 이동으로 다른 폴더를 삭제하고 이미지에서는"크기를 조정"폴더를,그러나 나는 다음과 같은 오류가:
"치명적인 오류가:허용한 메모리 크기의 33554432 소진 바이트(시도를 할당하 14172 바이트)/home/photogra/public_html/administrator/components/com_gallery/admin.gallery.php 선 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 };
또한 때 나는 오류를 이미지는 점점에 붙어"조정"폴더..킬 수 있는 사람이 있다면 도움이 될 것이다.:)
해결책
당신이 하려고 크기를 조정에 있는 모든 이미지는 디렉토리지 않고 메모리를 해제 후 각각의 하나입니다.도 추가
imagedestroy($img);
imagedestroy($tmp_img);
우선입니다.또한,연결을 해제 이미지로 당신이 그것으로 완료되면 보다는 오히려 반복을 통해 디렉토리에 두 번째 시간입니다.
제휴하지 않습니다 StackOverflow