0

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);
Tamil Selvan C
  • 19,913
  • 12
  • 49
  • 70
Mido Bona
  • 13
  • 6

1 Answers1

0

The upload_max_filesize, post_max_size and max_input_time settings can only be set in php.ini, .htaccess, httpd.conf and .user.ini. The max_execution_time can be set using ini_set.

See this link: Runtime Configuration. It describes where each php configuration option can be set.

See also Where a configuration setting may be set. It describes the different places where php configuration options can be set

Nadir Latif
  • 3,690
  • 1
  • 15
  • 24