I uploaded an image from iOS to cakephp by coding it to base 64 and this is my code on iOS :
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
NSString *encodedString = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
modelMFront.text = encodedString;
then I get the image on cake and tried to saved :
$filename_path = 'test'.".jpg";
$decoded=base64_decode($this->request->data['model_mfront']);
file_put_contents(WWW_ROOT.$filename_path,$decoded);
the problem is that the image is damaged http://imgur.com/a/LESJ3
any idea how to fix this ?!