My server-side code already works using postman, it doesn't work using Ionic
I'm trying to upload a image converted in base64 (about 2M) to a server using this function:
this.postPic = function(image,tags,title){
var dfd = $q.defer();
var req = {
method: 'POST',
url: baseURL+"utility.uploadpic",
data: "auth_token="+$localstorage.get("token")+"&tags="+tags+"&title="+title+"&base64_file="+image,
headers:{
'Content-Type' : 'application/x-www-form-urlencoded'
}
};
$http(req).success(function(response){
dfd.resolve(response);
});
return dfd.promise;
}
It gives me an error during upload ( showing me the message "Error creating file" in the following code)
function upload_pic($title,$tags,$base64_file){
$title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
$desc = $title;
$file_obj_string = base64_decode($base64_file);
//Creating file from string
$imgRaw = imagecreatefromstring( $file_obj_string);
if ($imgRaw !== false) {
.................
}
else{
return "Error creating file";
}
I don't know if it couldn't create the image from string because there is a size problem or something else. Any idea?