limit for uploading files [duplicate] - php

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
POST Content-Length exceeds the limit
PHP Warning: POST Content-Length of 113 bytes exceeds the limit of -1988100096 bytes in Unknown
I have form for upload images, I testing and if I upload image, where have for example 9 mb size, php returns error:
POST Content-Length of 10194008 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
I want that dont upload files more than 2 mb, in first line I have this code:
if (!empty($_FILES['main_photo']['name'])) {
if ( $_FILES['main_photo']['size'] > 1024 * 1024 * 2 ) {
header("Location: index.php");
exit();
}
}
but this error still displayed, please tell what make, I want if file more than 2 mb, just:
header("Location: index.php");

In php.ini look for upload_max_filesize and post_max_size and set to a suitable size:
upload_max_filesize = 20M
post_max_size = 20M
Only after that changes you can add your redirection code.
If you can't access your php.ini (shared hosting) try in .htaccess:
php_value upload_max_filesize 20M
php_value post_max_size 20M

The file you are trying to upload is larger than the configured size set in php.ini. Go inside of php.ini and modify these values to 2mb or greater to allow larger uploads:
upload_max_filesize
post_max_size <-- This one appears to be your biggest issue
Then your code should work.

Your server probably has setting to limit size to 8 megabytes, I think you code is ok. its a server problem try setting the upload_max_filesize using ini_set to something more. If you are one a commercial server , not your own, try contacting administrator

Related

phpMyAdmin File Limit (already edited php.ini)

I'm trying to import a 151 MB database into phpMyAdmin and am getting the error "You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit."
I've already edited php.ini with values of upload_max_filesize, memory_limit and post_max_size that more than accommodate this file. Is there anything else I can do to troubleshoot?
Try setting max_execution_time and max_input_time with higher values.
max_execution_time = 90
max_input_time = 120
You might want to try memory_limit as well and don't forget to restart the server.

How to change import limit on phpmyadmin running with wampserver? [duplicate]

This question already has answers here:
Can't import database through phpmyadmin file size too large
(13 answers)
Can not increase file upload size WAMP
(4 answers)
Closed 4 years ago.
I can only upload files up to 128 MB big on Phpmyadmin. I need to change the value, so I tried to change the php.ini file via tray.
I already changed memory_limit = 128M to memory_limit = 2048M and restarted all services, but the limit in Phpmyadmin is still 128 MB.
Do I have to change another setting?
Update:
I figured out that you can also set it directly via the tray menu, but it makes no difference (restarted already):
Interestingly there is still 128M selected even after I changed it to 2048M in the php.ini. I set it to 2048M again via the tray menu.
memory_limit = 2048M
post_max_size = 2048M
upload_max_filesize = 2048M
max_execution_time = 300
max_input_time = 300
Made no difference.
The duplicate 'Can not increase file upload size WAMP' solved the problem.

i want to upload video in codeigniter which max length is 200mb but i got error of max length even i set max length 200M in php.ini

public function add_video()
{
if(isset($_POST['add']) && $_POST['add']=='ADD')
{
move_uploaded_file($_FILES['video']['tmp_name'],'uploadimg/'.$_FILES['video']['name']);
$data = array('id'=>'', 'title'=>$_POST['title'],'video'=>$_FILES['video']['name'],'url'=>$_POST['link'],'status'=>$_POST['status'],'date'=>$_POST['date']);
$this->Dbfunction->insertdata('videos',$data);
redirect(base_url().'index.php/admin/videos');
}
}
And I Got Following Error
Warning: POST Content-Length of 177938307 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
Database Table Structure is follows
enter image description here
Try to set upload_max_filesize and post_max_size to 0 in php.ini
Create a file in PHP containing:
file.php
<----------- start -------------->
<?php
phpinfo();
<----------- end -------------->
Locate the line (Core): upload_max_filesize
If it is not the value you set in the php.ini file, or you changed the wrong file, or you did not restart apache
Also remember that you need to increase post_max_size and memory_limit too.

Changing post_max_size to 512M not being affected on WAMP

I have read other answers here on stackoverflow, however this is a really weird issue.
My phpinfo() shows that I have set 512M for the post_max_size (I have also increased other properties to at least 512M)
However when I am trying to send post request from Angular HTTP to Laravel 5.2 api, I get 422 Unprocessed Entitym and php_error says:
PHP Warning: Unknown: POST Content-Length of 7323588 bytes exceeds the limit of 3145728 bytes in Unknown on line 0
I have changed both php.ini files,despite only one being loaded.
Step 1: Go to the folder destination where you have installed WAMP. (Usually it is C:)
Step 2: Now locate and open php.ini files from both these locations. (C:\wamp\bin\apache\Apache2.4.4\bin and C:\wamp\bin\php\php5.4.16)
Step 3: Now in both the documents press CTRL+F and find out the following settings.
post_max_size
upload_max_filesize
memory_limit
For example you will see upload_max_filesize = 2m where m is MB. Change 2m to 500m or more as you like.
Change post_max_size = 8m to post_max_size = 700m or more. Change memory_limit = 8m to memory_limit = 1000m.
Other than that to avoid fatal errors like maximum time of something exceeded in line something, find and change the following values.
max_execution_time = 30 to to max_execution_time = 3000 and max_input_time = 60 to 3000.
This was an interesting problem.
The issue was following:
Yes, I needed to change the post_max_size, however at one point in my php.ini I had it set to 1000M.
My Apache 2.4.9 , and PHP 5.5.12 decided to ignore the suffix M and I ended up with a limit of 1000 Bytes.
My solution was to set post_max_size = 1000000 to have the limit set to 1MB

php.ini limit tricks $_FILES['userfile']['size']

In php.ini I have set:
post_max_size = 101M
upload_max_filesize = 101M
memory_limit = 128M
a php upload form uses can upload file up to 100M
a script will check if it doesn't exceed 100M
$img_size = $_FILES['bestand']['size'];
if ($img_size > MAX_EXTRA_FILE_FILE_SIZE){
$errors['tooBig'] = 1;
However, if a user uploads 125M, the server returns the message:
PHP Warning: POST Content-Length of ########### bytes exceeds the limit of ...
and the $error['tooBig'] will lose its value and no error message
will be returned to the user. Of course, i can just increase the ini.php:post_max_size endlessly, but even than a use could upload even larger files.
How do i tackle this?

Categories