“An error occurred in the upload. Please try again

2020-07-08 07:41发布

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.

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
7条回答
Fickle 薄情
2楼-- · 2020-07-08 08:13

My problem was with the functions.php file. The thread here helped me solve the problem.

查看更多
Emotional °昔
3楼-- · 2020-07-08 08:14

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.

查看更多
Ridiculous、
4楼-- · 2020-07-08 08:15

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.

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.

screenshot

查看更多
5楼-- · 2020-07-08 08:21

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.

查看更多
虎瘦雄心在
6楼-- · 2020-07-08 08:27

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.

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.

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.

查看更多
我命由我不由天
7楼-- · 2020-07-08 08:29

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.

sudo apt-get install imagemagick

and then a restart of the web server solved the problem.

查看更多
登录 后发表回答