简体   繁体   English

从iOS上传到PHP后端时为UPLOAD_ERR_PARTIAL

[英]UPLOAD_ERR_PARTIAL when uploading from iOS to PHP backend

I have an iOS app that is uploading images to a PHP backend using NSURLConnection and NSMutableURLRequests, the usual. 我有一个iOS应用程序,该应用程序通常使用NSURLConnection和NSMutableURLRequests将图像上传到PHP后端。

Every once in a while, but with seeming regularity, we're getting UPLOAD_ERR_PARTIAL PHP upload errors when images are uploaded from devices to the server. 从设备上载图像到服务器时,每隔一段时间,但似乎有规律性,我们会收到UPLOAD_ERR_PARTIAL PHP上传错误。 Now I suppose some of the time it could be due to loss/degradation of signal on people's phones and such. 现在,我想有些时候可能是由于人们电话等设备上信号的丢失/衰减所致。 But I did some research and it seems these errors can be caused by issues with headers, eg Keep-Alive (see http://www.bizzeh.com/739/php-problem-with-upload_err_partial-file-upload-error-code-3 ). 但我进行了一些研究,看来这些错误可能是由于标头问题引起的,例如Keep-Alive(请参阅http://www.bizzeh.com/739/php-problem-with-upload_err_partial-file-upload-error-代码3 )。 It's suggested that setting header("Connection: close"); 建议设置header("Connection: close"); could solve the issue. 可以解决问题。

The thing I'm not clear on is where to set connection close? 我不清楚的事情是在哪里关闭连接? Is that a header that should get sent along with the POST request from the app? 那是应该与应用程序的POST请求一起发送的标头吗? Or something we should set on the backend every time an image upload completes? 还是每次上传图片完成后都应在后端设置一些内容?

Also, if you think this could be solved by something other than the above, let me know. 另外,如果您认为上述方法可以解决上述问题,请告诉我。

Thanks for any guidance! 感谢您的指导!

After some research online, it maybe solved by inserting a small bit of code as explained by: 经过一些在线研究之后,可以通过插入少量代码来解决该问题,如下所述:

"This is an old post, but I had a random problem of UPLOAD_ERR_PARTIAL, and post my solution. The problem is that after 2/3 upload I obtained an error of UPLOAD_ERR_PARTIAL, without any interruption by the client. My problem was related to the Keep-Alive server. I solved it by inserting at the end of the PHP script for uploading header ("Connection: close");" “这是一个旧帖子,但是我遇到了UPLOAD_ERR_PARTIAL的随机问题,并发布了我的解决方案。问题是,在2/3上传之后,我得到了UPLOAD_ERR_PARTIAL的错误,而没有客户端的任何干扰。 Keep-Alive服务器。我通过在PHP脚本的末尾插入用于上传标头(“ Connection:close”);”解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM