• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Send files from iphone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Send files from iphone


  • Subject: Re: Send files from iphone
  • From: Development <email@hidden>
  • Date: Fri, 3 Jul 2009 22:21:13 -0700

It's the smallest errors that create the greatest frustration. I left out a semi colon. and misspelled boundary. Which makes me wonder why the examples I found didnt work.

On Jul 3, 2009, at 9:34 PM, Development wrote:

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

_______________________________________________

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


References: 
 >Send files from iphone (From: Development <email@hidden>)
 >Re: Send files from iphone (From: Luke Hiesterman <email@hidden>)
 >Re: Send files from iphone (From: Development <email@hidden>)
 >Re: Send files from iphone (From: Development <email@hidden>)

  • Prev by Date: Re: looks like my syntax is wrong. Does not compile
  • Next by Date: Re: looks like my syntax is wrong. Does not compile
  • Previous by thread: Re: Send files from iphone
  • Next by thread: Re: Send files from iphone
  • Index(es):
    • Date
    • Thread