i am using ajax and php to upload file i have this input
<input id="up_file" style="display:none;" accept=".gz" type="file" />
and this is javascript :-
$('#up_file').on("change",function() {
var file_data = $('#up_file').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
if (file_data){
$.ajax({
url: 'upload_backup.php',
cache: false,
contentType: false,
processData: false,
data: form_data,
async: false,
type: 'POST',
success: function(data){
$("#message").append(data);
$('#reload i').click();
}
});
}
});
and this is php code
<?php
$filename = $_FILES['file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext == "gz"){
$file_name =str_ireplace('.sql.gz','',$_FILES['file']['name']);
$size =formatSizeUnits($_FILES['file']['size']);
$file_path ='backup_db/' . $file_name.'.sql.gz';
move_uploaded_file($_FILES['file']['tmp_name'],$file_path);
}else{
echo "Error Ext <br>";
}
?>
i try this but not working
ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);