现象
wordpress媒体库中上传文件出错:Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.
同时,直接在文章页面上传文件也出错:The response is not a valid JSON response
解决
wordpress默认会限制上传文件的大小,但我肯定不是这个问题,我很早就将这个限制修改了。
我在wordpress前使用了nginx做反向代理,问题也就出在这,解决方法:
在nginx的配置文件 http{}
模块中修改最大允许的请求体大小 client_max_body_size
:
http {
client_max_body_size 256M;
server{...}
...
}
重新加载配置文件或重启nginx即可