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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com