I've a problem: I want to send a picture from my iOS app to a php script to insert this image in a mysql db. The field in mysql db for the image is LONGBLOB. The image that is sending is _photoImageView.image The method I created in Xcode is as follows:
NSData *dataForImage = UIImagePNGRepresentation(_photoImageView.image);
NSMutableString *strURL = [NSMutableString stringWithFormat:@"http://localhost/myfff/join.php?username=%@&password=%@&photo=%@",_txtUsername.text,_txtPassword.text, dataForImage];
[strURL setString:[strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:strURL]];
[request setHTTPMethod:@"POST"];
postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
In the php script in the affected part, I do this:
$data = addslashes(fread(fopen($_FILES[photo], "rb"))); $query = "INSERT INTO mytb VALUES (' ','$username','$password'','$data')";
The insertion does not occur .. where am I wrong? Help me please!