For send ajax form i use this code :
<input type="file" class="file_1" id="file" />
My jQuery code :
var file = $('#file').val();
$.post('form.php', {file:file}, function(data){});
And my PHP code :
if($_FILES["file"]["tmp_name"] != '') {
$fileName = $_FILES["file"]["name"];
$fileTmpLoc = $_FILES["file"]["tmp_name"];
$fileType = $_FILES["file"]["type"];
$fileSize = $_FILES["file"]["size"];
}
echo $fileName;
But this code not work
I think that you can´t. Nevertheless, there are some tools that "emulate" it. Check up this tutorial: http://hayageek.com/ajax-file-upload-jquery/
Or this question: Is it possible to use Ajax to do file upload?
You are trying to post a adress name (on the other words you post a string) but file upload needs to be a file. then you can find the answer from the this link: