i am trying to upload a image to server from iPhone application
PHP code for upload image is following
if(isset($_POST[\'insertImage\']))
{
You wrote the server code to only accept data with certain specified content types, but then you never added the content type to your data. Simply emit the correct content type for your image data:
// Emit the content type here as well
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
[postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"imageFile\"; filename=\"myimagefile.png\"\r\nContent-Type: image/png\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]];
[postBody appendData:[NSData dataWithData:userImageData]];
[postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]];
The error is actually coming back from your own server response, so simply following the flow of control on your server code gives you the cause.