简体   繁体   中英

upload_max_filesize doesn't change within Laravel 5.1

I'm working on multiple file upload while that time I've got an error

The file "theOne.mp3" exceeds your upload_max_filesize ini directive (limit is 2048 KiB) .

So after that I've increased the post_max_size = 20M and upload_max_filesize = 20M and checked it within test.php file it shows

截屏

Even though it shows 2M within my Laravel Project and throws the error. What could be the reason behind this.

So finally I've solved it by myself might be I got downvoted for this but I don't know this worked for me even after apache2 restart that won't effect within my project but after that I've restarted my entire system and it all works fine for me. The reason might be because of the cache memory but I'm not sure about that

Try this it may work ...

Create a file named php5.ini and copy and paste the below code into it. Then save it. Then upload it. php_value won't work in an ini file. It probably doesn't work because you left php_value before each line.

file_uploads = On
upload_max_filesize = 20M
post_max_size = 20M
upload_tmp_dir = /tmp/

Then save the file as php5.ini and upload it to the root of your site.

As you told you have changed the upload_max_filesize and post_max_size in your php.ini

What are the suspected issues

  1. Make sure change in the correct php.ini file if you have multiple installation of apache

  2. Make sure that you have restarted your apache server

Note :

If you have written laravel rules change it accordingly like this, but it should not be the major issue

public static $updaterules = array(
    'uploadedimage' => 'image|max:5000'            
    );

In my case I was running php artisan server in order to run laravel the server. So the changes applied for apache were not applied to php cli .

Apache

在此处输入图片说明

PHP CLI

在此处输入图片说明

What I recommend to everyone that faces this problem is:

  1. print phpinfo()
  2. search line Loaded Configuration File and see which file you have to modify
  3. modify it, save, and restart your server.

Hope this helps

Restart PHP artisan serve (if you are using it).

I did all of the recommendations to no avail only to realise that I never restarted my PHP artisan serve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM