EDIT I'm trying to send several input values trough jQuery / ajax() with a file in it and ajax() doesn't seems to support both in the same time. I've found that FormData would do the trick. Using jQuery ajax to upload file and form data with formData() http://www.thefourtheye.in/2013/10/file-upload-with-jquery-and-ajax.html
UPDATE I don't have any errors anymore but the file is not uploaded properly into the MySQL DB/LongBlob columb. It seems to be properly received now in the PHP file.
html
<input type=hidden name=catselid id=catselid value=".$id.">
<input name=city id=city>
<input name=country id=country>
<input type=file name=picture id=picture >
<input name=update value=update type=submit class=update id=update />
javascript
$(".update").click(function(){
$.ajax({
url: 'catsel_change.php',
type: 'POST',
contentType:false,
processData: false,
data: function(){
var data = new FormData();
data.append('picture',$('#picture').get(0).files[0]);
data.append('city' , $('#cityname').val());
data.append('country', $('#country').val());
data.append('id', $('#catselid').val());
return data;
}(),
success: function(result) {
alert(result);
},
error: function(xhr, result, errorThrown){
alert('Request failed.');
}
});
});
php
if(is_uploaded_file($_FILES['picture']['tmp_name'])){
$picture =addslashes (file_get_contents($_FILES['picture']['tmp_name']));
...
}
FYI, I'm using jQuery 1.9.1 comments/suggestions are welcome regards