简体   繁体   中英

Prevent request timing out - large POST data

In my iOS app, to post a new question, I make a HTTP POST request to http://api.mysite.com/questions . The POST data is obviously larger or smaller depending on whether an image is attached to the question or not. Small (sized around 100-200kb) images are POSTed to the server without a problem. However, larger photos (~1mb), from the device's camera cause the request to time out due to the large size of the image.

Please can you tell me how I can make sure that the image is uploaded without a problem, this doesn't seem to happen for many other apps.

Is it a problem with the server or with the iOS code itself?

Edit----

On the server, once the request has been received, the PHP just writes the image data to a file. The blob is the image data:

$filepath = $this->debug == true ? "../cityw/img/questions/{$qid}/attachment.png" :"../i/questions/$qid/attachment.png";

if (!file_exists($this->debug == true ? "../cityw/img/questions/{$qid}" : "../i/questions/{$qid}")) {
    mkdir($this->debug == true ? "../cityw/img/questions/{$qid}" : "../i/questions/{$qid}");
}

$fh = fopen($filepath, 'w');

fwrite($fh, $blob);
fclose($fh);

The image data is sent to the server in BASE64, and then decoded once it has reached the server.

Have you tried fixing your problem with set_time_limit

Glad that worked out for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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