You cannot use AJAX to download files (unless client browsers support the HTML 5 element, which allows access to the file object.).
Your decision should fake it
create form element
<form id="myForm" action="upload.php" method="POST" target="results_frame"> <input name="fileUpload" type="file" /> <input type="submit" value="Submit" /> </form>
We set the frame target for 'results_frame', we define it after the form in HTML as an empty iframe.
<iframe id="results_frame" name="results_frame" style="display:none;"></iframe>
Then in the backend in your php file you can write the file as -
$_FILE['file']['param']; //where param accepts multiple values //such as name, type, size, error, and tmp_name
After you have processed the file, you can echo any information that you need, including updating the initial form at this point.
source share