PHP - File uploading process resets - php

I'm trying to upload files over 150MB with a PHP file, which works without any problem with files less than 40Mb. But when I try to upload files like 150 to 200 MB, it resets the upload process after uploading about half of the file.
It repeats again and again when the new upload process gets to same value, till the time limits on php.ini file kills the process.
The first thing I tried was increasing those values in my php.ini file:
post_max_size=450M
memory_limit=300M
max_execution_time=1600
max_input_time=1600
upload_max_filesize=400M
and file_uploads is of course set to On.
I also put this line to top of my upload.php file:
set_time_limit(0);
I'm running that website on Windows Server 2008 R2 with Parallels Plesk 12.0.8.
I search this problem on Google too much but none of the solutions work on my case.
I read the same scenario in this question, which the owner of the question replied that he solved the problem by increasing client_max_body_size value in nginx.conf file, but I could not find anything about this file in Windows server so I thought it is only exists on Linux systems.
What could cause this problem?

I've solved it.
I changed PHP's debugger from FastCGI Application to CGI Application on Plesk, and that solved it.
But be careful, it caused me a couple of errors in other pages of the website, and I've fixed them all again.
Hope that helps.

Related

Unable to upload large files

I have a laravel project that uses AJAX to send files to be uploaded to the server. All works just fine for as long as the file is less than 100MB. But large files like 450MB and up are not being saved on the server despite receiving a response that the file has been saved.
I am using Apache and my php.ini files have both max_upload_size = 1024MB and max_post_size = 1024MB.
Please help, any info that will be of helping in debugging I can provide.
Thanks.
I know its been long, since I posted this question and I found the answer a long time. But just in case someone is also having the same issue.
It turns out I had a .htaccess file in the public folder that was overiding the server configurations for this specific virtualhost.

PHP file upload - out of memory

I have a Symfony application using Sonata admin and Sonata media my client uses to upload mp4 videos. The problem is these files are getting bigger and bigger (> 1go) and I now have trouble with "out of memory" apache errors.
The website is hosted on an AWS EC2 ubuntu instance (PHP, Apache2).
I set the php.ini parameters like this:
upload_max_filesize = 1G
post_max_size = 2G
memory_limit = -1
I did this for cli and apache2 under /etc/php/7.0/. I tried various combinations and higher values. Always restart apache afterwards. I even tried rebooting the instance. I can't get to upload more than 350mo.
Are you sure of the right syntax ? I think it's in bytes like
1000 bytes = 1Mo so just write the number without "G","Mb",etc..
But im not sure try it and return response :)
OK, I found a solution. Here's how I did it.
First of all, i stopped my EC2 instance, detached the volume and made a snapshot of it.
From the snapshot, I created a bigger volume (30Go for now). I reattached it to my EC2 instance, which I rebooted.
I logged in through SSH and installed a swapspace (3Go). Tweaked it a little following this.
I cleant the cache, restarted my EC2 instance one last time and... well I just uploaded 1Go in 20 minutes.
One issue though : stopping and starting my EC2 instance I lost my IP and had to change my DNS zone. It's gonna take a few hours for the website to be back...
Hope this will be helpful to someone.
Can you check your .htaccess file in the project root directory or make sure that in the Symfony project files, the size is not limited with the PHP functions, which will overwrite the php.ini attributes.
Edit your php.ini file upload_max_filesize = 100000
Because if you write 1G it will not count 1 GB it sounts in byte so you will have to declare 1048576 for uploading limit of 1 GB

Upload Size PHP

I am developing a web application which will allow the administrator to upload a file and its max size is 500M.
I have changed the post_max_size = 500M and upload_max_filesize = 500M from 32M but the funny thing is that it does not allow me to upload files greater than 32M still.
I have restarted the server and everything and still cant get to upload a large file.
Is there any other setting i should change to allow me to upload the file?
I am not going to process the file in memory but move it to the tmp folder and than process from there with move_uploaded_file so memory_limit i am assuming that is not going to be affected.
It is a simple form and as i recall if the limit is exceeded in the $_FILES superglobal array i should see something in the error element of the array but instead i get an empty array.
EDIT: I am modifying the php.ini settings but from phpinfo i am still getting the sizes of 32MB. And the php error log says that obviously i am exceeding 32MB
Can you please help me out.
Thanks
Chech phpinfo() on a web page, see which php.ini is loaded. You could be editing the wrong file.
Sometimes different ini files get loaded for command line and apache server use
I fount out what the problem is:
I am using MAMP as a developing server and MAMP has templates which override the original every time the server starts (a stupid thing IMO) so you need to change the template for it to take effect!
The template can be found under /Applications/Mamp Pro/Contents/Resources
And there many php ini files for every version will be found.
Hope this helps to the next one!

Joomla 3.2 Increase the upload_max_filesiz

I am trying to download this template on Joomla 3.2 extension manger :
http://scriptmafia.org/templates/115622-yt-moustache-yootheme-for-joomla-25-32.html
but every time I upload it, it gives me this error:
There was an error uploading this file to the server.
I have read articles about "increase the upload max size in the php.ini file".
I have tried to find this file in the administrator files section in Joomla, but it is "not found".
So how can I fix this problem? It has not happened for this template only, it has happened for several. So I am almost sure it is due to the upload size.
Edit your php.ini and increase *upload_max_filesize* and *post_max_size*; then restart your web server.
If you don't know where is your php.ini, create a php file to discover: echo php_ini_loaded_file();
The returned path is where your php.ini is located.
EDIT
Well, seems like you have a permission error and not size limit. Try to change permissions of the temp Joomla folder (you can see/configure it on Global Configuration > System).
If you are using XAMPP , php.ini file will be located in c:\XAMPP\php folder. Find the file and increase file upload size there.
If you are using WAMP, You can find ini file in /wamp/bin/php directory.
The location may vary from one OS to another.
You can follow this link:
http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/
You can call in your script ini_set function and change values, which have been stored in php.ini (any changes has affected only for current script, but not for global settings)
ini_set('post_max_size', "%value in MiB for example 16M%")
ini_set('upload_max_filesize', "%value in MiB for example 16M%")
You can read more about it at php.net
If you can't resolve the PHP limitation easily, an alternative is to FTP the installation file to the /tmp folder and in Extension Manager -> Install, use the "Install from Directory" option instead.
Had the same issue for the longest time, none of the answers helped. Found that if you are using GoDaddy, and go to your CPanel, scroll down to Software, then choose PHP version, switch to PHP Options, there you can change your upload file size. Hope this helps, took me forever to find it.
Some people might be having a issue with the memory allocation portion of php.ini file "memory_limit" the default for me was 128mb and i was attempting to upload nearly 300mb and it hit that roadblock. After changing the default value to 512mb and restarting the server i was able to get past this limit.
How to change post_max_size and upload_max_filesize in a local installation of Joomla 3 in XAMPP
You can check the php setting in two places – site’s backend under system information – go to php information. Or on browser go to localhost and click on phpinfo. You’ll find the post and upload part under “Core” heading.
Go to c:\xampp\php\
Find the file php.ini
Open php.ini in notepad
Find post_max_size and change value to 20M
Find upload_max_filesize and change value to 20M
Save the file
Logout out of your site backend.
Turn off apache and mysql on xampp and quit
Restart xampp as administrator
Turn on apache and mysql
Open browser and go to localhost
Open phpinfo and search for upload_max_filesize and post_max_size.
Confirm that changes are registered.
This can also happen with the following suhosin setting:
suhosin.upload.disallow_binary = On
Setting it to off temporarily allows you to upload zip files
If you use CPanel, search for PHP version (in the Software section) and click on it, then click on 'switch to PHP Options', the options will display then look for 'upload_max_filesize' and click on the value to change it. Do the same for 'post_max_size'.

JQuery File Upload 500 Internal Server Error

I've been stuck on this for about a week and I just seem to be going around in circles.
The problem is receiving a 500 Internal Server error when uploading files. I've posted around a few forums but help is extremely limited due to me running a Windows Server.
So what have I done so far?
Checked, double checked, triple checked the PHP.INI file to make sure I have all the correct attributes set:
max_execution_time 600
max_input_time 600
memory_limit 128M
post_max_size 50M
upload_max_filesize 50M
Checked over the script and decided to test a few different scripts from various sources W3Schools, PHP.net etc same problem.
Upgraded PHP5 to PHP5.3 same issue
Tried to implement it using the JQuery_File_Upload API and I got unstable results. Rarely it would upload >10MB files and almost always threw out a Internal Server Error
Checked the error log. I checked it but nothing out of the ordinary in there and last write was a few days ago so I added a custom log and again, nothing being written to it.
What else can I do? I'm running a dedicated server, Windows 2008, Plesk.
Please help!
Thanks.
I resolved this issue by checking the /var/log/apache2/error_log files. Saw something there that indicated that a.htaccess file was being read, so i went to that dir and opened the .htaccess file:
server/php/files/.htaccess
Then commented out the below line by putting a hash in front of it:
Header set X-Content-Type-Options "nosniff"
Then browsed to the directory and it worked fine.

Categories