douchui4459 2014-11-12 03:28
浏览 25

致命错误:允许的内存大小。 请帮忙

Hello Guys please help me.

Here's my code,

Line 1 -    $imagename = $_FILES['file']['name'];
Line 2 -    $source = $_FILES['file']['tmp_name'];
Line 3 -    $target = "images/".$imagename;
Line 4 -    move_uploaded_file($source, $target);
Line 5 -
Line 6 -    $imagepath = $imagename;
Line 7 -    $save = "images/" . $imagepath; //This is the new file you saving
Line 8 -    $file = "images/" . $imagepath; //This is the original file
Line 9 -
Line 10 -   list($width, $height) = getimagesize($file); 
Line 11 -
Line 12 -   $tn = imagecreatetruecolor($width, $height) ; 
Line 13 -   $image = imagecreatefromjpeg($file); 
            imagecopyresampled($tn, $image, 0, 0, 0, 0, $width, $height, $width, $height) ; 

            imagejpeg($tn, $save, 80) ; 

            $save = "thumb_/" . $imagepath; //This is the new file you saving
            $file = "images/" . $imagepath; //This is the original file

            list($width, $height) = getimagesize($file) ; 

            $modwidth = 130; 

            $diff = $width / $modwidth;

      $modheight = 185; 
      $tn = imagecreatetruecolor($modwidth, $modheight) ; 
      $image = imagecreatefromjpeg($file) ; 
      imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width,     $height) ; 

      imagejpeg($tn, $save, 80) ;

I have error here.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 13056 bytes) in C:\xampp\htdocs\MagicLine\admin\cleo\cleo.php on line 13

  • 写回答

2条回答 默认 最新

  • dsh84723 2014-11-12 03:39
    关注

    You need to raise your memory limit in your php.ini file. The 128MB limit was exhausted when it tried to allocate 13KB more for one of the operations.

    http://php.net/manual/en/ini.core.php#ini.memory-limit

    You can set this in run time by using ini_set().

    Note: It is typically unusual for a PHP script to utilize 128MB of memory on its own, but it depends on what you are doing. I don't have experience with these image functions, so you would have to decide if this is normal usage or if you have a memory leak somewhere in your script.

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析