将图片上传到编辑器时,wordpress 中出现“上传时出错。请稍后再试”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21726630/
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
"An error occurred in the upload. Please try again later" in wordpress when uploading images to editor
提问by John
I finally found the solution to this problem which as turns out plagues many wordpress installations. Right after uploading an image through the "add media" button in an editor, the upload would fail with a "an error occurred in the upload error". However after refreshing the image would appear in the media browser window but when inserted into the editor it would show up with width and height both set to 1px.
我终于找到了这个问题的解决方案,结果证明它困扰着许多 wordpress 安装。通过编辑器中的“添加媒体”按钮上传图像后,上传将失败并显示“上传错误中发生错误”。然而,刷新后图像会出现在媒体浏览器窗口中,但当插入编辑器时,它会显示宽度和高度都设置为 1px。
After searching a lot without any success I solved the problem. Many people reported solving it by disabling all plugins one by one to find which was causing the problem. In my case it was a fresh wordpress installation without anything else, not even custom themes. So I decided to post it here in case anyone else is search and stumbles upon this post.
在搜索了很多没有任何成功之后,我解决了这个问题。许多人报告说通过一一禁用所有插件来找到导致问题的原因来解决它。就我而言,这是一个全新的 wordpress 安装,没有其他任何东西,甚至没有自定义主题。所以我决定把它贴在这里,以防其他人在搜索并偶然发现这篇文章。
采纳答案by John
Turns out the culprit was imagemagick. I disabled it in php.ini and everything started working again. If your host supports it you can use a custom php.ini file.
原来罪魁祸首是imagemagick。我在 php.ini 中禁用了它,一切又开始工作了。如果您的主机支持它,您可以使用自定义 php.ini 文件。
回答by Chris Paris
I found a simple solution. If you save the post you are working on as a draft, then attempt the upload again, it works. This appears to happen if you have been drafting a document for a long time, without manually saving. Once you manually save, it resets the upload ability somehow, and the problem goes away.
我找到了一个简单的解决方案。如果您将正在处理的帖子保存为草稿,然后再次尝试上传,它会起作用。如果您长时间起草文档而没有手动保存,则会出现这种情况。手动保存后,它会以某种方式重置上传功能,问题就会消失。
回答by Andrei G.
Sometimes this problem comes with uploading/restoring the db-backup from file via phpmyadmin. The import can skip adding auto_increment
to wp_posts
and wp_postmeta
tables at 0
key.
有时这个问题是由于通过 phpmyadmin 从文件上传/恢复 db-backup 引起的。导入可以跳过添加auto_increment
到键wp_posts
和wp_postmeta
表0
。
This leads to crash in the further work of the site and eventually you wan't be able to add new posts/pages ("you are currently editing the page that shows your latest posts" instead of the text editor), upload new images (you'll see the empty window where once was all your image gallery).
这会导致站点的进一步工作崩溃,最终您将无法添加新帖子/页面(“您当前正在编辑显示最新帖子的页面”而不是文本编辑器),上传新图像(您将看到曾经是您所有图片库的空窗口)。
The issue can be easily fixed by deselecting the checkbox near the "Do not use AUTO_INCREMENT for zero values" when importing DB through import
section of phpmyadmin. However, it still can be imported with errors and you'll need to add auto_increment
to wp_posts
and wp_postmeta
tables manually after the import complete.
在通过import
phpmyadmin 部分导入数据库时,通过取消选中“不要将 AUTO_INCREMENT 用于零值”附近的复选框,可以轻松解决该问题。然而,它仍然可以有错误的进口,你需要添加auto_increment
到wp_posts
和wp_postmeta
导入完成后手动表。
回答by SteveSong
In my case, I had moved moved wordpress to a new server and was getting this error. It turned out that I hadn't installed imagemagick on the new server.
就我而言,我已将移动 wordpress 移至新服务器并收到此错误。原来我没有在新服务器上安装imagemagick。
sudo apt-get install imagemagick
and then a restart of the web server solved the problem.
然后重新启动网络服务器解决了这个问题。
回答by zipzit
I too had this issue with a plugin I wrote. Root cause seems to be a WordPress interference with the javascript call window.requestAnimFrame
. Info provided here for anybody else searching on the error message.
我写的一个插件也有这个问题。根本原因似乎是 WordPress 干扰了 javascript 调用window.requestAnimFrame
。此处为搜索错误消息的其他人提供的信息。
The plugin I wrote was a simple little thing to post a fixed box on the top of the screen that showed browser window size. The plugin would update four times / second using window.requestAnimFrame
calls. I'm guessing something in the routine that updated the media upload progress bar interferes with the call. And I was all set to publish that plugin too, sigh.
我写的插件是一个简单的小东西,可以在屏幕顶部张贴一个显示浏览器窗口大小的固定框。该插件将使用window.requestAnimFrame
调用更新四次/秒。我猜测更新媒体上传进度条的例程中的某些内容会干扰通话。我也准备发布该插件,叹息。
Not sure of the exact details on why this makes WordPress media uploads fail, but its yet another root cause. Note: the media files did actually upload, but the feedback system just errors out on the admin end. Note: not sure I was supposed to, but I submitted a bug report to core WordPress.
不确定为什么这会导致 WordPress 媒体上传失败的确切细节,但这是另一个根本原因。注意:媒体文件确实上传了,但反馈系统只是在管理端出错。注意:不确定我应该这样做,但我向核心 WordPress 提交了错误报告。
回答by Nadi
Please see this link for more details - it helped me https://sebastian.expert/fix-wordpress-an-error-occurred-in-the-upload-please-try-again-later/
请参阅此链接了解更多详细信息 - 它帮助了我 https://sebastian.expert/fix-wordpress-an-error-occurred-in-the-upload-please-try-again-later/
Basically what it says is to use Developer tools in Chrome or Firefox to see the response from async_upload.php file after uploading files (when error message appears). It returns error details in JSON format. Having details it will be easier and a lot faster to resolve the problem.
基本上它说的是在上传文件后(出现错误消息时)使用 Chrome 或 Firefox 中的开发人员工具查看来自 async_upload.php 文件的响应。它以 JSON 格式返回错误详细信息。有了详细信息,解决问题会更容易、更快。