php 在 WordPress 中上传图片时出现“文件为空”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9115556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error "file is empty" when uploading images in WordPress
提问by Armin Cifuentes
I'm running a WordPress 2.9.2Blog with a custom install of Debian in a Amazon Web Services EC2machine.
我正在运行一个WordPress 2.9.2博客,并在Amazon Web Services EC2机器上自定义安装了 Debian 。
Everything was working fine until monday. Then came tuesday, and suddendly, overnight, I can't upload pictures using the default WP file uploader (either flash or html).
一切正常,直到星期一。然后到了星期二,突然间,一夜之间,我无法使用默认的 WP 文件上传器(Flash 或 html)上传图片。
When I try to upload a picture, it displays the following error:
当我尝试上传图片时,它显示以下错误:
File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini
文件为空。请上传更实质性的内容。此错误也可能是由于 php.ini 中禁用上传或 post_max_size 被定义为小于 php.ini 中的 upload_max_filesize 引起的
So I checked out my php.ini, and modified some settings as follows:
所以我检查了我的php.ini,并修改了一些设置如下:
- upload_max_filesize: 64M
- post_max_size: 90M
- memory_limit: 128M
- max_excecution_time: 600
- max_input_time: 600
- 上传最大文件大小:64M
- post_max_size: 90M
- 内存限制:128M
- 最大执行时间:600
- 最大输入时间:600
But it didn't work. Then I tried chmod-ing the wp-content/uploads/folder and its subfolders to 777. Didn't work.
但它没有用。然后我尝试chmod-ing wp-content/uploads/文件夹及其子文件夹到777。没用。
Did some research on Google, and added following lines to .htaccess:
对谷歌做了一些研究,并在.htaccess 中添加了以下几行:
<IfModule mod_security.c>
SetEnvIfNoCase Content-Type
"^multipart/form-data;" "MODSEC_NOPOSTBUFFERING=Do not buffer file uploads"
</IfModule>
<IfModule mod_gzip.c>
mod_gzip_on No
</IfModule>
Didn't work. Finally, increased WPs memory limit in wp-settings.phpfile. Didn't work.
没用。最后,增加了wp-settings.php文件中的WPs 内存限制。没用。
So I'm all out of options by now. Anyone has any ideas on how to solve this? It's really bugging me and my client off!
所以我现在已经别无选择了。任何人都对如何解决这个问题有任何想法?这真的让我和我的客户感到厌烦!
Thanks in advance!
提前致谢!
采纳答案by Armin Cifuentes
Not sure if this was the case (it has been over a year), but in many cases, for this same issue, the problem was due the hard drive being full.
不确定是否是这种情况(已经一年多了),但在许多情况下,对于同一问题,问题是由于硬盘驱动器已满。
Stupid, I know.
愚蠢,我知道。
Just check how much space is left, and, if none, go delete logs. Apache, PHP, MySQL. They add up a lot of data when enough time is given.
只需检查剩余空间,如果没有,则删除日志。Apache、PHP、MySQL。当有足够的时间时,它们会将大量数据相加。
回答by Odysseus Ithaca
First I created a file called phpinfo.php and put this in it:
首先,我创建了一个名为 phpinfo.php 的文件并将其放入其中:
<?php
phpinfo();
?>
I accessed the page (I'm using wamp) at localhost/phpinfo.php and checked
我在 localhost/phpinfo.php 访问了页面(我正在使用 wamp)并检查
upload_max_filesize:
post_max_size:
memory_limit:
I found the location of php.ini and changed these variables upwards to
我找到了 php.ini 的位置并将这些变量向上更改为
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 128M
Then I restarted apache and checked that phpinfo.php reflected the new settings. I was still getting the error, so I changed the directory for the site and all sub directories from read-only to read-write. That seemed to do the trick.
然后我重新启动 apache 并检查 phpinfo.php 是否反映了新设置。我仍然收到错误消息,因此我将站点和所有子目录的目录从只读更改为读写。这似乎奏效了。
回答by Luis
I had a similar problem. I receive the "empty file" message and proceed to reload the same file that just report the warning. A lot of messages saying " media xxxx already exists" appears and after check, all the posts have been imported with all the attachments. So basically I had to upload each import file twice but on second time it was faster. Hope it helps.
我有一个类似的问题。我收到“空文件”消息并继续重新加载刚刚报告警告的同一个文件。出现很多“媒体xxxx已存在”的消息,经过检查,所有帖子都已连同所有附件一起导入。所以基本上我不得不将每个导入文件上传两次,但第二次上传速度更快。希望能帮助到你。