I have mp3 upload form. When i upload my project on server the mp3 upload not work, i echo file name, size and tmp_name, it return file size is 0 and tmp_name is blank. But when upload jpg image i got file name, size, tmp_name.
What i tried code mention in below:
upload Form:
<form class="needs-validation row" id="add-form" enctype="multipart/form-data">
<input type="file" id="audio" name="audio" class="form-control">
<button id="btn-submit" class="btn btn-primary" type="submit" ><i id="addclasses" class="fa fa-check"></i> Submit</button>
<span class="error" style="color:red;"></span>
</form>
Ajax call code:
<script>
$("#add-form").on('submit', (function(e) {
event.preventDefault();
$.ajax({
type: 'POST',
data: new FormData(this),
url: 'add-form.php',
cache: false,
contentType: false,
processData: false,
success: function(response) {
if(response == 1){
$('.error').html("<span>File upload successfully</span>");
}else{
$('.error').html(response);
}
}
});
}));
</script>
and my server side code:
<?php
echo $_FILES['audio']['name'].'<br>';
echo $_FILES['audio']['tmp_name'].'<br>';
echo $_FILES['audio']['size'];
exit();
?>
here is referance link file upload
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…