The iPhone app implements the function of uploading videos to the server.
I succeeded in uploading the video using AFNetworking, but
If the capacity of the video increases, it seems to fail.
Specifically, if the capacity exceeds 10MB, it always fails.
If you want to upload such a large file, click
Is it better to find another way instead of using AFNetworking?
Please let me know if you know more.
·Objective-C
// Get video
NSSstring*dir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents";
NSSstring* path = [dir stringByAppendingPathComponent:@"test.mov";
NSData* videoData=[NSDataDataWithContentsOfURL:[NSURL fileURLWithPath:path]];
// Upload Video
AFHTTPRequestOperationManager*manager = AFHTTPRequestOperationManager manager;
manager.responseSerializer = AFHTTPResponseSerializer;
[manager.requestSerializer setTimeoutInterval:50];
[manager POST:@"(omitted)/deployMovieTest.php" parameters:nil constructionBodyWithBlock:^(id<AFMultipartFormData>formData){
[formData appendPartWithFileData:videoDataname:@"movie"fileName:@"test.mov"mimeType:@"video/quicktime";
} success:^(AFHTTPRequestOperation* operation, id responseObject) {
NSLog(@"Success: Show JSON %@", responseObject);
NSSstring* responseStr = [[NSSstring alloc] initWithData: responseObject encoding:NSUTF8 StringEncoding];
NSLog(@"Success: Display characters %@",responseStr);
} failure:^(AFHTTPRequestOperation*operation, NSError*error){
NSLog(@"Failure:%@", error);
}];
·php
<?php
// Information received at POST is in $_FILES.
// Receive video at POST.
$image=file_get_contents($_FILES['movie']['tmp_name']);
// Created the destination URL to be moved.
$uploaddir='(omitted)/uploads/';
$uploadfile=$uploaddir.basename($_FILES['movie']['name']);
// Saved the file.
$message="";
if(move_uploaded_file($_FILES['movie']['tmp_name'], $uploadfile)){
$message="OK!\n";
} else{
$message="NO:)";
}
// output
header('Content-type:application/json');
echo json_encode($message);
?>
コメント I solved the problem by commenting, but I will also write it down in the person who answered.I would like to ask the viewer to approve this answer as they know that it has been resolved.
The server said PHP, so I tried to estimate the cause.
In php, the php.ini setting has a "upload_max_filesize" setting, which limits the size of the file to upload.This value must be set to the maximum expected value of the file you want to upload (the specified value is set to a smaller value such as 2M or 10M).
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
582 PHP ssh2_scp_send fails to send files as intended
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.