Answer the question
In order to leave comments, you need to log in
Upload files from ajax?
<form method="post" enctype="multipart/form-data" id="file-form">
<div class="form-group">
<label for="dfile">Загрузить файл можно только XLSX Бдьте уверены в этом!</label>
<input type="file" name="dfile" id="dfile" class="form-control">
</div>
<div class="form-group">
<!--<input name="submit" type="submit" value="Send" class="btn btn-success" id="upload-button">-->
<button type="submit" id="upload-button">Upload</button>
</div>
</form>
<h4 id='loading' >loading..</h4>
<div id="message"></div>
<script>
$(document).ready(function (e){
$('#upload-button').click(function (e){
e.preventDefault();
$("#message").empty();
$('#loading').show();
});
$.ajax({
url: 'UpdateCitymarket.php',
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(data) // A function to be called if request succeeds
{
$('#loading').hide();
console.log(data);
$("#message").html(data);
}
})
})
</script>
if(isset($_FILES["dfile"]["type"])){
echo "hello";
}
Answer the question
In order to leave comments, you need to log in
your click is closed..
});
$.ajax({
$(document).ready(function (e){
$('#upload-button').click(function (e){
e.preventDefault();
$("#message").empty();
$('#loading').show();
// });
$.ajax({
url: 'UpdateCitymarket.php',
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success: function(data) // A function to be called if request succeeds
{
$('#loading').hide();
console.log(data);
$("#message").html(data);
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question