Note that there are some explanatory texts on larger screens.

plurals
  1. POsend zip file from ios app to php server
    primarykey
    data
    text
    <p>I am building a client-server app in which the app is sending a zip file that contains a lot of images and the php server should check if the file was received and returns the number of the images in the zip file that was sent.</p> <p>here is my code in the app: </p> <pre><code> NSData *zipData = [[NSData alloc] initWithContentsOfFile:zipFile]; // zipFile contains the zip file path NSString *postLength = [NSString stringWithFormat:@"%d", [zipData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://localhost/test.php"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:zipData]; NSHTTPURLResponse* urlResponse = nil; NSError *error = [[NSError alloc] init]; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;urlResponse error:&amp;error]; NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"Response Code: %d", [urlResponse statusCode]); if ([urlResponse statusCode] &gt;= 200 &amp;&amp; [urlResponse statusCode] &lt; 300) { NSLog(@"Response: %@", result); } </code></pre> <p>and here is my php file that runs on local host using xampp:</p> <pre><code>&lt;?php print_r($_POST); print_r($_FILES); ?&gt; </code></pre> <p>the zip file is attached to the request using sethttpbody, I am trying to view the file in the php as shown above but it is always empty, please help me with that , moreover is that right to see the sent zip file by printing the $_POST and $_FILES if not what is the right way to do that, the zip file is converted to NSDATA, also I have checked that the connection is established but I am really confused with this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload