How to compress multiple images and upload in FTP server from iPhone app?
You should definitly try out this library -> http://code.google.com/p/objective-zip/ . I've had good results zipping up to 3 images. Guess 25 will work as well
EDIT:
Here's a post of mine which has some sample code wich you can use :)
How can I convert my Zip-file to NSData to email my Zip file as an attachment
How to upload image either .png or .jpg on ftp server in ios.?
Finally i got success to upload image file on ftp server.
To upload image on ftp i used Gold Raccoon external library.with this library you can easily upload image to ftp server.
https://github.com/albertodebortoli/GoldRaccoon
Upload File to FTP Server on iPhone
I use a PHP Page to post a file to and have PHP handle the uploading....
This code is used to upload a photo, but it can be adapted to work with any file.
PHP Code:
<?php
$uploaddir = 'photos/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "OK";
} else {
echo "ERROR";
}
?>
iPhone Code:
- (BOOL)uploadImage:(NSData *)imageData filename:(NSString *)filename{
NSString *urlString = @"http://www.yourdomainName.com/yourPHPPage.php";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@\"\r\n",filename]] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding] autorelease];
return ([returnString isEqualToString:@"OK"]);
}
Method Call:
[self uploadImage:UIImageJPEGRepresentation(imageView.image, 1.0) filename:imageName];
Related Topics
Adding Constraints Programmatically in UIview with UItextview
Swift How to Make List Start at The Top with No Padding
Swiftui - How to Change The Button's Image on Click
Swiftui Map Overlays Without UIviewrepresentable
Why Does a Function Have Long-Term Write Access to All of Its In-Out Parameters
Understanding Optional Global Variables in Swift
Underlying Type for Tuple in Swift
Aws Cognito Credentialsprovider.Login Always Shows Nil (Swift)
Why Is My App Returning Hundreds of Errors That Say "Undefinedsymbol"
Delete Tableview Cell, and Remove Data from Firebase
#If Canimport(Coreimage) Not Working in Swift Package Manager
Can't Dismiss View Controller That's Embedded in a Navigation Controller
Rlmexception', Reason: 'Attempting to Modify Object Outside of a Write Transaction
Swift 3 Custom Extension of Ns Measurement? Ex. Sheeps to Goats
Uiview.Animatewithduration Not Animating
How to Fill Triangle in Swift Using Core Graphics
How to Make a Function Operate on a Sequence of Optional Values
Os X App Doesn't Launch New Window on Dock Icon Press in Swift