I try send a file via jQuery to a PHP file for processing.
<form action="help-uploader.php" method="POST" class="signup" id="upform" enctype="multipart/form-data">
<input type="text" id="title" name="title" tabindex="1" value="">
<input id="file" type='file'" />
<button class="submitbtn" id="submit">submit</button>
</form>
and jQuery:
$(document).ready(function(){
$('#submit').click(function (e) {
// custom handling here
e.preventDefault();
var ititle = $("#title").val();
var ifile = $("#file").val();
$.post("help-uploader.php",
{
title: ititle,
file: ifile
},function(data, status){alert("Data: " + data + "\nStatus: " + status);});
});
});
and **help-uploader.php**
<?php
echo $_POST['file'];
echo basename($_FILES["file"]["name"]);
?>
First ECHO prints path of file in client.
Second ECHO not prints anything.
How can I send a file to PHP via jQuery correctly?