Upload big file using PHP - php

I'm trying to upload big files using PHP and it's not working and the size is around 855 ko. I've already tried uploading smaller files and its worked so i'm sure that my problem that causing the error.
I've already tried most of the solution in SO and google but in vain. Some said that i should try to configure my php.ini and i did but without success.
I'm using lighttpd on an embedded system.
My php.ini configuration :
max_execution_time = 300; Maximum execution time of each script, in seconds
max_input_time = 25200; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 40M ; Maximum amount of memory a script may consume (128MB)
file_uploads = On
upload_tmp_dir =/home/imagesdcard/www/
upload_max_filesize = 10M
max_file_uploads=2
I had tried many solutions that suggesting it was caused by certains configurations in php.ini and i had changed it but without success.So, i wanna ask how can i upload big files using php?
Thank you in advance for all advice and help and have a great day.

By configuration, PHP only allows to upload files up to a certain size. There are lots of articles around the web that explain how to modify this limit. Below are a few of them:
PHP Increase Upload File Size Limit
How do I increase the PHP upload limits?
For instance, you can edit your php.ini file and set:
memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
You will then need to restart apache.

Related

Why can't I upload large files on my PHP website?

I am having a problem with uploading files bigger than a certain size (around 150MB/200MB) to my server.
Because I do not have this problem on my local server, I suspect it has something to do with settings on the shared server which I rent that runs Apache.
The error that I am getting is HTML error 413 Request Entity Too Large
Ofcourse I have done some research and found that the php settings on the server are set correctly as follows:
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 2048M
post_max_size = 2048M
memory_limit = 4096M
max_input_vars = 2000
Furthermore, because the server runs on Apache, I made sure to also add
LimitRequestBody 2147483647 and
SSLRenegBufferSize 2147483647 to the .htaccess file which translate to 2GB for both settings.
For the code I just use the PHP move_uploaded_file($_FILES["video"]["tmp_name"], "../videos/". $newVideoName)) method which, one again, does work with smaller files.
Is anyone familiar with this problem or have any other solutions on how to fix this problem? I did talk the my host and they have said that there aren't any restriction on uploaded filesizes other than the PHP settings which I have changed.
Thanks upfront!

How to change max upload size for files in Wordpress 4.4 at xampp

I wanted to upload a template to wordpress 4.4 which is running on xampp but it says that I only can upload 2MB. I've googled the problem and found an information that i need to change the parameter upload_max_filesize=32M in the file php.ini. I doesn't found the file in the Wordpress folder but in the xampp folder I found a file called php.ini with the parameter in it and I changed the parameter but nothing happened.
What can I do to increase the max template upload space?
Have you tried this already? http://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/ It contains plenty of ways to increase the max upload size.
Make sure you increase post_max_size and upload_max_filesize, both limits.
So for example in PHP.ini:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Cause it may take longer to upload those files, you might want to increase max_execution_time as well.
post_max_size is the maximum size for all POST body data. upload_max_filesize is a maximum size only for files that are POSTed. Other types of POST body data are not subject to this limit. See Brad's answer over here: PHP post_max_size vs upload_max_filesize, what is the difference?

Increase File Upload Size Wordpress / IIS 7

I'm trying to increase the file upload size in a Wordpress blog to allow an admin to post his e-books and large PDF files. The site is hosted on GoDaddy / IIS 7. I have tried the following with no luck:
web.config:
<configuration><system.webServer><security><requestFiltering><requestLimits maxAllowedContentLength="10000000"/></requestFiltering></security></system.webServer></configuration>
php.ini in root of site:
upload_max_filesize = 64M
Any advice is greatly appreciated.
Thanks,
Shawn
Solution found here:
Step 1:
First, you need to edit your server’s PHP.ini file. This is found in
your PHP installation directory, e.g. c:\program files\php\php.ini and
set the following values:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
This allows PHP to handle files up to 64MB and allows PHP scripts to
run up to 5 minutes before timing out.
Step 2:
Lastly, IIS 7 has a default file upload limit of 30MB. Anything larger
than that will cause IIS to return a very unhelpful 404 status. You
can read more about it at
http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits
To override this, you need to change the web.config settings for
(each) site. (The only catch here is that the limits are expected to
be in bytes instead of kilobytes.) The following is some copypasta
from the MSDN docs:
Don’t forget to recycle your application pool so IIS picks up your
PHP.ini changes.
And that’s it!
http://refactored.tumblr.com/post/4609761388/wordpress-iis7-uploads
you will have to modify the active php.ini which you can get get from a phpinfo() and change both post_max_size and upload_max_filesize accordingly. Once done, restart iis
I had to adapt the first solution above, because I am using Windows Share HostGator site. I had a file in httpdocs called: .user.ini, which I added:
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 600
max_input_time = 600
Because I needed it bigger. I also added:
<security><requestFiltering><requestLimits maxAllowedContentLength="268435456"/>
</requestFiltering></security>
So this allowed me upload larger files. I wanted to be able to upload large videos or mp3 files.

How to increase my upload limit in php

I read so many articles out there in the internet and found that to change the php.ini file to upgrade the upload limit. But I do all the suffs and cant upload more than 10mb of files or so.
I am trying to add a feature to upload video file through the front end for users. But failed for some reason
Is there any other way to do it. Or is it because it is a video file or some thing like that
Make sure that you have (in php.ini, .htaccess, etc.):
increased post_max_size to at least twice the max file size that you might need to upload
increased upload_max_filesize to the max file size that you might want to upload
increased memory_limit to something bigger than post_max_size
On top of setting php.ini
upload_max_filesize = 200M
post_max_size = 200M
I owuld look into a flash uploader like uploadify. It will make your life much easier trust me.
Since you are changing the php.ini, are you restarting the webserver so that the changes take effect (if using mod_php)? Does the webserver itself have any restrictions set?
It's been a while since I've done this, but in my php.ini I have upload_max_filesize = 200M and I have post_max_size = 200M
I also set max_execution_time = 3000 If this is set too low, it'll cut off while the user is still uploading.
You should also bump up max_input_time and memory_limit

Changing the upload limit in php

I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?
Cheers
Here's what I recommend changing (assuming Apache & PHP):
I've found this works well for up to about 30mb attachments
PHP Settings
max_execution_time = 120
max_input_time = 120
memory_limit = 30M
post_max_size = 30M
upload_max_filesize 30M
file_uploads = On (although it sounds like you already have this turned)
Apache Settings
LimitRequestBody 31457280
You need to set upload_max_filesize, post_max_size and memory_limit appropriately. post_max_size must be larger than upload_max_filesize, because there needs to be memory allocated for the request headers as well as the file payload.
In your php.ini:
; Maximum allowed size for uploaded files.
upload_max_filesize = 50M
; Maximum size of POST data that PHP will accept.
post_max_size = 50M
What errors are you getting in your error log once these have been done? Is it possible that your uploaded file is running foul of the memory limit on the script?
You can set the memory limit higher for this particular script by including the following line in your script:
ini_set("memory_limit","75M");
Make sure you changed upload_max_filesize AND post_max_size
As long as you have restarted your web service (ie apache) then the changes should take effect, however if you are developing for anyone other then yourself then instead of changing the php.ini I would add this to the upload script:
ini_set('upload_max_filesize', '10M');
as some people may not be able to modify php.ini this will change it just for the page it is on.

Categories