I have a video upload system in an iOS app using NSURLSessionUploadTask. The video file is saved to NSURL, so I use the following code in the upload method:
request.HTTPMethod = @"POST";
[request addValue:@"file" forHTTPHeaderField:@"fileName"];
NSURLSessionUploadTask *task = [session uploadTaskWithRequest:request fromFile:filePath completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if(!error) {
} else {
}
}];
[task resume];
I have a PHP server (using Laravel) running under nginx to handle this download. I tested it using Postman and it accepts downloads in order (expecting a file called "file").
When I run the above objc code, the server tells me that the file was not loaded (the array is $_FILESempty).
I tried with and without setting the "fileName" header, and I tried setting the "Content-Type" to "multipart / form-data", but none of these functions work.
NSURLSessionUploadTask ( NSURL) ?
, , : NSURLSessionUploadTask php script