Upload filesize limit in CodeIgniter seems to be ignored - php

I am working on a CodeIgniter project that involves file uploads. When I try to upload a file 2.2MB (default upload size limit in CI is 2MB = 2048KB) it works with no problem. But when I try something bigger (21.5MB) it returns:
[msg] => You did not select a file to upload"
I changed the max_size parameter to both "0" and "204800" (200MB in KB), but still nothing works. You will say to check my php.ini file, but I already did and the max_upload_size directive is set to 200M, which also phpinfo() confirms.
So, please tell me, what am I doing wrong and which is the right way to do it?

If you are using POST to upload your files, you may also want to change your htaccess file.
php_value upload_max_filesize 2M

Related

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!

Try to upload .zip file using ftp_put function but it is not able to upload large file(more than 1 MB)

I am using the following code to upload a .zip file, but am unable to upload a file of size greater than 1MB:
$upload = ftp_put($conn_id, $target_path.'/'.$filename, $source, FTP_BINARY);
Any thoughts?
Have you changed the config settings at php.ini max_file_uploads to a latger value, the values are taken as MB so give something as large as 5
I am sure it should work.
changing in php.ini will result in php application that is running.
changing in htaccess file will result in project
changing in a php file will result in php file and its included files
Choosing which one is based on your recuirements.
Use, upload_max_filesize this will control the size of file to be uploaded.
post_max_size is the size of data posted in side form elements.
it could be file, input, checkbox... etc. So this also has to be altered based on file size.
You should adjust both upload_max_filesize and post_max_size to perform file operation and others...
Have you checked error_log . If not check that, and find out what exactly the problem is, and if using apache, you can set the php.ini setting in .htaccess . Like this
php_value upload_max_filesize 20M
Paste this .htaccess file and you will be able to upload the file. Also,check error_log for exactly what is causing the issue.

Increasing the Upload Limit of my PHP script

I have a simple PHP script. Its used to upload users into the joomla tables. Basically it uploads users into joomla three main tables.
The PHP uploader sript works fine when the CSV is about 80MB to 100 MB.
It does not work or just nothing happens when the file size is 500MB or above.
How do i make the PHP script work to upload the CSV files of over 500 MB?
Do i actually change something in my PHP.ini settings or is there something else i could
add in the script itself.
Thanks in Advance.
in the .htcaccess file add the following:
php_value upload_max_filesize 500M
php_value post_max_size 500M
in php.ini add:
upload_max_filesize = 500M
post_max_size = 500M
You have to change the upload_max_filesize in php.ini
I had the same issue long time ago with rails and mysql,
You have to consider 3 things when you want to upload a file:
Max upload file in PHP
Be sure that MySQL will save a big file.
Your browser will lost connection after a while uploading a file to your database if it don't receive any answer from the server.
I think that You handled the first 2, but to handle the 3rd probably you will need a upload progress bar to keep the session active. Actually you need some AJAX to keep the server and the client "talking" meanwhile the file still uploading.

PHP File Upload problems when uploading "larger" (over 2MB) files

I am having problems trying to upload "larger" files, and I believe the limit that I'm allowed is about 2MB. I've uploaded multiple filetypes below 2MB (.js, .png, .jpg, .psd, .php), however anything over about 2MB fails.
1.8MB psd image worked
2.4MB psd image didnt' work (same file as 1.8, just bigger)
I've already changed php.ini to the following:
upload_max_filesize = 20M (changed this from 2M)
post_max_size = 40M (changed this from 2M)
max_execution_time = 60 (changed this from 45)
max_input_time = 180 (changed this from 30)
memory_limit = 48M (Changed this from 8M)
I've also added the following to my htaccess file in both the final directory where I'd like the file to be moved, and the initial directory where the upload form lives:
LimitRequestBody 53687091
Like I mentioned, the upload is working for smaller files, so I believe it has to be a restriction on the upload size, not anything wrong with the form.
Any ideas as to where I can look next? I want the limit to be 20M, it's all on our backend with a login required to access the page, so I am not worried about rouge uploads.
Confirm that your upload_max_filesize / post_max_size is INDEED updated.
Sometimes users don't know which php.ini file to edit.
Best way is to create file (that you delete later) and add the following code:
<?php
phpinfo();
?>
Run that file to get your system settings (search for upload_max_filesize, etc);
Have you tried restarting your web server since making the changes?

PHP: Having trouble uploading large files

I am doing a file upload using PHP, which works fine for a file of size 2.8MB on my localhost - but not my Mediatemple GS host. Files smaller than 2MB work fine, but anything larger seems to not work... I am not getting any error message but when the upload finishes, the file is not found in the uploads directory...
I googled around, and I added the following lines to the .htaccess file:
php_value memory_limit 120M
php_value max_execution_time 120
php_value upload_max_filesize 10G
php_value post_max_size 10G
I know some of the above values are a overkill, but even then, this does not seem to help... Anything else I might be missing?
The one you missed is max_input_time, and do check whether your edits are reflected in phpinfo();.
Check the phpinfo() and look for these four values - it's possible that the changes you think you're making haven't been applied, or that something else is overriding your changes. The values you've changed look correct to me.

Categories