Coding issue while uploading picture to server! why this code makes error?
<p>I am trying to upload some data to web service using post action
But the following error happens on didReceiveData.</p>

<pre><code>400 Bad Request
a 404 Not Found
</code></pre>

<p>Can you please help me on this coding issue?</p>

<pre><code>NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
NSMutableData *postData = [[NSMutableData alloc] init];
NSString *boundary = [NSString stringWithString:@"------------------147378098Aadfsn1987XdaoTwq"];

// First name
[postData appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"Content-Disposition: form-data; name=\"firstname\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[firstName dataUsingEncoding:NSUTF8StringEncoding]];

NSData  *photo = UIImageJPEGRepresentation(takePhoto, 0.5f);
// Photo data
[postData appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"Content-Disposition: form-data; name=\"picture1\"; filename=\"photo.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
if (takePhoto != nil) {
    [postData appendData:photo];
}

NSString *postLength = [NSString stringWithFormat:@"%d", postData.length];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
</code></pre>
