Hello, I would like to send an excel file to a php page, where I would read the data and then send it to the database. I was able to do this by giving a refresh of the page, but wanted that when the file was sent there would appear a message of success (alert), without refresh.
<form action="uploadexcel.php" enctype="multipart/form-data" method="POST" >
<input type="file" name="file" >
<input type= "submit" value ="Enviar" >
</form>
I tried to make a modification to use jquery, but I do not have much knowledge and it did not work. This is the code, it does not refresh but does not send the file in a format suitable for php.
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#ajax_form').submit(function(){
var formdata = new FormData($("#ajax_form"));
jQuery.ajax({
type: "POST",
url: "uploadexcel.php",
data: formdata,
processData: false,
contentType: false
success: function( data )
{
alert( data );
}
});
return false;
});
});
</script>