File upload fails laravel - php

so I created simple form to upload files and dd the $request->file
<form
action="/videos"
method="post"
enctype="multipart/form-data"
id="upload_form"
name="upload_form"
>
#csrf
<input type="file" name="avatar" />
<input type="submit" value="submit" />
</form>
dd($request->file('avatar');
if the video is above 1 mb but less than 8 mb it get's uploaded with error 1 and a size of 0 mb if the video is above 8 mb I get an error
Illuminate\Http\Exceptions\PostTooLargeException
PHP Warning: POST Content-Length of 21712952 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
this is my php.ini file inside laravel
post_max_size = 100M
; upload_max_filesize = 60M
variables_order = EGPCS
max_execution_time = 3600s
memory_limit = 100M
upload_max_filesize = 60M

Your php.ini config is fine. The problem is in the nginx config.
You must increase the client_max_body_size. The default value of it is 1 MB per file.
Add the following in your default.conf of your nginx project:
server {
...
client_max_body_size 128M;
...
}

Related

"Maximum file size allowed for upload: 0 bytes" showing while uploading files

"Maximum file size allowed for upload: 0 bytes" showing while uploading files. I have increased the limits via php.ini.
max_execution_time = 30
max_input_time = 60
max_input_vars = 1000
memory_limit = 128M
post_max_size = 500M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php72"
upload_max_filesize = 128M
But NO RESULTS!! Any solutions?!
Ensure to restart your server every time you make changes in php.ini
also, these links will be helpful as they discuss same issue :
https://forums.cpanel.net/threads/maximum-file-size-allowed-for-upload-0-error.564011/
https://forums.cpanel.net/threads/how-do-i-increase-the-upload-limit-in-my-cpanel.69018/

Laravel - TokenMismatchException in VerifyCsrfToken because of upload filesize

I have found that i need to change these settings in order to upload bigger files
I have changed these settings in my php.ini file
upload_max_filesize = 32M
max_file_uploads = 20
and this in my nginx.conf file
client_max_body_size 40m;
but i still get this error:
PHP Warning: POST Content-Length of 27772457 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
This is 8MB limit....but where...i have restarted my machine and it still doesn't work
Where else can i adjust the file upload limit?
in your php.ini you should also change your
post_max_size
and make it larger than your upload_max_filesize
for exemple i use :
post_max_size = 125M
upload_max_filesize = 100M
then restart php-fpm

I'm trying to upload large files via ajax but im getting "Error: Request entity too large"

I´ve got my limitrequestbody set to 0 on apache and on phpI have post_max_size and upload_max_filesize to 50M and max_input_time to 2 m. But when I try to upload a file of 4 mb I get this error. I have a hosting account on godaddy.
My .user.ini has these lines
upload_max_filesize = 50M
post_max_size = 50M
max_input_time = 130
and my .htaccess
LimitRequestBody 0

uploading files greater than 8 mb in php

Warning: POST Content-Length of 11313557 bytes exceeds the limit of
8388608 bytes
I am getting this above warning. I searched around internet and I have also increased the the following limits in php.ini:
max_input_time = 600000;
max_execution_time = 60000000;
file_uploads = On;
upload_max_filesize = 1000M;
post_max_size = 1000M;
and also in mysql.ini file i have changed
max_allowed_packet = 100M;
but still I get the following warning. Files less than 8mb are easily uploaded but greater than 8mb pops up the above error message.
You need to set the value of upload_max_filesize and post_max_size in your php.ini :
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
And then you should stop your apache service and then start your apache.
In case of linux based systems
/opt/lampp/lampp stop
/opt/lampp/lampp start
In case of windows just stop and stop your apache or your xampp service.
Check the phpinfo page and see you have edited the correct configuration file. Loaded configuration file can be found in phpinfo page under Loaded Configuration File
Add as first line at your process file
set_time_limit(0);

PHP unable to fetch the PDF file name in upload form

I can't upload PDF file using PHP.
I have tried to get the name of file only for testing.
HTML:
<form action="add.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload" name="submit" />
</form>
add.php:
<?php
echo $_FILES['file']['tmp_name'];
?>
I got an error message:
"Notice: Undefined index: file in C:\wamp\www...".
but it worked for another files.
Please help me!
Your code looks fine, so its probably a problem to do with file size limits.
Add the following to .htaccess and see if it makes any difference.
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
You could also make the changes in your php.ini like this:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300

Categories