Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chhoda

macrumors 6502
Original poster
Oct 25, 2008
285
1
Code:
[postbody appendData:[[NSString stringWithFormat:@"param1=%d&param2=%f&param3=%@", 1, 3.0, [txtDesc text]] dataUsingEncoding:NSUTF8StringEncoding]];
	
	[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
	[postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
	[postbody appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];

I am trying to upload a file with some additional info as post variables.

in php side i get the file upload properly, but when i do $param1 = $_POST['param1'] i get a blank.

what am i doing wrong ?

--CH
 
I would suggest reviewing the samples here, specifically the last chunk of code at the bottom.

I believe the problem is you need a Content-Disposition header for each name-value pair.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.