Re: Send files from iphone
Re: Send files from iphone
- Subject: Re: Send files from iphone
- From: Development <email@hidden>
- Date: Fri, 3 Jul 2009 21:34:48 -0700
Ok I have made a tiny bit of progress.
The problem is that the _POST and _FILE arrays are still empty Well...
the _POST array on the server is filled with a mix of the data it
should have scrambled in with jpeg data. I desperately need help I
cannot find the answer for this for some reason. I've been googling
for hours now and the example code doesn't work either.
Below is the sending code:
NSMutableData * sendData= [[NSMutableData alloc]init];
NSMutableData * body= [[NSMutableData alloc]init];
NSString * boundry = @"@@##$$rew**&&^%^";
NSString * name=[path lastPathComponent];
NSString * dir= [path stringByDeletingLastPathComponent];
[body appendData:[[NSString stringWithFormat:@"--%@\r
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition:
form-data; name=\"%@\"\r\n\r
\n",@"fileName"]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString
stringWithFormat:@"%@",name]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition:
form-data; name=\"%@\"\r\n\r
\n",@"directory"]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString
stringWithFormat:@"%@",dir]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition:
form-data; name=\"image_file\" filename=\"%@\"\r\n\r
\n",name]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n"
dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:imageData];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r
\n",boundry]dataUsingEncoding:NSUTF8StringEncoding]];
int totalSize =[body length];
NSLog(@"Total size: %i",totalSize);
[sendData appendData:[@"Content-Type: multipart/form-data;
boundary=@@##$$rew**&&^%^\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[sendData appendData:[[NSString stringWithFormat:@"Content-Length: %i
\r\n\r\n",totalSize]dataUsingEncoding:NSUTF8StringEncoding]];
[sendData appendData:body];
[self startConnection];
[self sendMainHeadersForPage:@"/image.php"];
[self sendData:sendData];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden