I know not working is a vague problem-description. In console I see the error:
TypeError: $(...).files is undefined
Here is the jQuery code used to send the Ajax request:
$(document).ready(function(){
$("input[type=submit]").click(function(e){
e.preventDefault();
e.stopPropagation();
$.ajax({
url : "",
type : "POST",
data : $('input[type=file]').files[0],
success : function(){
console.log("Successfully done!");
},
});
});
});
Here is the HTML:
<form method="POST" enctype="multipart/form-data">
<label >Please Select a File to Upload</label><br />
<input type="file" name="name" /><br /><br />
<input type="submit" value="Upload" name="upload" />
</form>
and Here is the PHP to process to upload the file:
session_start();
if(isset($_POST['upload']))
{
print_r($_FILES);
move_uploaded_file( $_FILES['name']['tmp_name'] , 'up/'.$_FILES['name']['name'] );
echo "File uploaded Successfully";
echo "<br />" . "<br />";
}
All the above code simply are in a single page.