Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple file uploads with PHP script and iOS
    primarykey
    data
    text
    <p>Currently I'm uploading a xml file from mac to a server. It works fine. Below is the code:</p> <p><em><strong>osx code</em></strong></p> <pre><code> NSString *urlString1 = @"http://username:pwd@ip/files/upload.php"; NSMutableURLRequest *request1 = [[NSMutableURLRequest alloc] init]; [request1 setURL:[NSURL URLWithString:urlString1]]; [request1 setHTTPMethod:@"POST"]; NSString *boundary1 = @"---------------------------14737809831466499882746641449"; NSString *contentType1 = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary1]; [request1 addValue:contentType1 forHTTPHeaderField:@"Content-Type"]; NSMutableData *body1 = [NSMutableData data]; [body1 appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary1] dataUsingEncoding:NSUTF8StringEncoding]]; [body1 appendData:[@"Content-Disposition: form-data; name=\"userfile\"; filename=\"data.xml\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body1 appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body1 appendData:[NSData dataWithData:xmlData]]; [body1 appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary1] dataUsingEncoding:NSUTF8StringEncoding]]; [request1 setHTTPBody:body1]; NSLog(@"xml data %@",xmlData); NSData *returnData1 = [NSURLConnection sendSynchronousRequest:request1 returningResponse:nil error:nil]; </code></pre> <p>and <strong><em>PHP script</em></strong>: </p> <pre><code> &lt;?php $target_path = "./"; $target_path = $target_path.'data.xml'; if(move_uploaded_file($_FILES['userfile']['tmp_name'],$target_path)) { echo "The file has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?&gt; </code></pre> <p>Now I have a case where I'm supposed to add multiple files. So how does file naming work? Anyone please help me on this.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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