0
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 managed to do this by refreshing the page, but I wanted when the file was sent to appear a successful sending message (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 don’t know much and it didn’t work. This was the code, it does not refresh but does not send the file in proper format to 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>
Hello, I tried this way but it didn’t work. I don’t know if this changes anything, but my php reads the excel file and sends it to mysql.
if (!empty($_FILES['file']['name'])) {
 ...
however I put an error msg in case it was not excel file or this error and msg does not appear. Therefore it is not calling my php for what I understood.– felipetn