上传照片时允许的内存大小为 67108864 字节已耗尽错误 [英] Allowed memory size of 67108864 bytes exhausted ERROR when uploading a photo

查看:44
本文介绍了上传照片时允许的内存大小为 67108864 字节已耗尽错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站有点问题.

人们使用此页面在我的网站上创建帖子,您可以在其中附加照片.所有照片都在工作,除了那一张.(链接见下文)

People use this page to create a post on my site, you can attach photos to it. All photos were working ecept that one. ( see below for the link )

当我尝试将其上传到帖子"页面时,它说:

When I try to upload it on the "post" page it says:

我的女朋友正在尝试上传它,在上传之前,她用 Windows 7(在预览模式下)旋转图片,这样图片就会在右侧.

My girlfriend is the one that is trying to upload it , before uploading it she rotate the picture with windows 7 ( in preview mode ) so the image would be on the right side.

PHP 致命错误:第 65 行/home/(rest of path)/upload.php 中允许的内存大小为 67108864 字节(试图分配 3411201 字节)

PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 3411201 bytes) in /home/(rest of path)/upload.php on line 65

upload.php 上的第 65 行 = $tmp=imagecreatetruecolor($newwidth,$newheight);

line 65 on upload.php = $tmp=imagecreatetruecolor($newwidth,$newheight);

我一直在寻找一种方法来反击"该错误 2 天.

I've been looking for a way to "counter" that error for 2 days.

有人可以帮我吗?

它只显示该图像的错误,我不知道旋转是否是问题...

It only show that error with that image, I don't know if the rotate is the problem...

非常感谢

推荐答案

问题是您的脚本内存不足.现在,您似乎为每个 PHP 脚本分配了约 64mb.令人惊讶的是,它使用的比这更多(除非您上传大照片!),但是当您将以下内容放在脚本顶部时会发生什么?

The problem is your script is running out of memory. Right now it seems that you have ~64mb allocated per PHP script. It is amazing that it is using more than that (unless you are uploading huge photos!), but what happens when you put the following at the top of your script?

ini_set('memory_limit', '128M');

这将暂时提高该脚本的内存限制.如果您发现需要为脚本分配更多内存,那么如果您不想使用 ini_set(),则必须更改 php.ini 中的值.

This will raise the memory limit temporarily for that script. If you find that you need to allocate more memory for your script, then you'll have to change the value in php.ini if you don't want to use ini_set().

它可以工作还是内存不足~128mb?

Does it work or does it run out of memory ~128mb?

<小时>注意:
如果这是个人项目,这个解决方案是可以的.如果这比这更大,我会接受 matino 的建议并限制您的上传大小.


NOTE:
If this is a personal project, this solution is ok. If this is something bigger than that, I would take matino's advice and limit your upload size.

这篇关于上传照片时允许的内存大小为 67108864 字节已耗尽错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆