问题描述:

I have following codes in my PHP classes:

...

success: function(response){

if(response==='Successs'){

$('.'+input.id + ' .info_danger_text').html('');

$('.'+input.id + ' .progress-bar').removeClass('active progress-bar-striped ').addClass('progress-bar-success')

console.log(response);

}

else if(response==='sizeError') {

$('.'+input.id + ' .progress-bar').removeClass('active progress-bar-striped ').addClass(' progress-bar-danger');

$('.'+input.id + ' .info_danger_text').html('Илтимос, хажми 2мг дан кичик бўлган файлни юкланг');

}

} ,

......

and

$fsize=$_FILES[$key]['size'];

if($fsize > 2097152){

echo "sizeError";

return;

}

else{

if(move_uploaded_file($_FILES[$key]['tmp_name'],$name )){

echo 'Successs';

} else {

echo 'fail';

}

}

}

This code works in the local version of my web application. However, it is not working in the online version. It is not returning a size error (for a file which size is larger than 2MB). How can I fix this issue?

网友答案:

Please make sure that you added java-script library into your page. If not please add it.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
网友答案:

Keep this, before your code,

ini_set('post_max_size', '64M'); 
ini_set('upload_max_filesize', '64M');

OR make changes related to these attributes in your php.ini file as

post_max_size 64M
upload_max_filesize 64M

And then restart server, if apache,

then run

sudo service apache2 restart

From terminal.

It should work.

相关阅读:
Top