file upload strange error

Discussion in 'iOS Programming' started by chhoda, Sep 29, 2010.

  1. macrumors 6502

    Joined:
    Oct 25, 2008
    #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
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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.
     

Share This Page