Hello everyone I am posting a sample code in which I am uploading a file using Ajax JQuery. All thing works fine but I want to read the file content in my php code. So what
The first argument you pass to FormData.append()
is the name of the form element that is passed to the server. So data.append('file', alpha)
in your case is equivalent to <input type="file" name="file">
- you passed 'file' to append() so 'file' is your input name.
You should find your stuff in $_POST['file']
and $_FILES['file']
. Next time try var_dump($_POST);
after submit to see the array. :)
Learn about file uploads in php here: http://php.net/manual/en/features.file-upload.php