1

I am uploading profile images to a directory on the server. The script works fine, however I can't seem to get anything but small file size images to upload. Anything above about 2mb fails. I don't have access to the php.ini but I have added the following to htaccess with no luck. I have tried every other solution I can find online with no luck. Any ideas?

php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_input_time 400
php_value max_execution_time 400
6
  • 1
    Did you restart your webserver after making changes to your php.ini file? Commented May 16, 2012 at 3:54
  • he doesn't have access to the php.ini file Commented May 16, 2012 at 3:56
  • I am on a shared server and don't have access to the php.ini. I was under the impression that I could do the same with .htaccess? However, that is not working. Commented May 16, 2012 at 3:56
  • Ah, does ini_set() work for you? Also, take a look at step #2 and step #3 here php.net/manual/en/features.file-upload.php#107406 Commented May 16, 2012 at 3:59
  • 1
    @ChiragShah upload_max_filesize is PER_DIR, not INI_ALL Commented May 16, 2012 at 4:00

2 Answers 2

2

First, check phpinfo() to see what the runtime settings are; if they still show 2M (default), Apache is probably not obeying the .htaccess file

Normally I would tell you to make sure you have this in the virtual host declaration of your Apache configuration:

AllowOverride Options FileInfo

But being on a shared host doesn't give you those permissions (highly unlikely). You should check with your hosting provider to see whether they can raise those limits for you by adding the php_value settings inside your virtual host

Alternatively, work around the issue by chunking the upload files (e.g. upload 1MB at a time) as suggested by @Satya.

Sign up to request clarification or add additional context in comments.

4 Comments

It says under phpinfo() upload_max_filesize 20M... so Im not sure what is going on??
You should also look at max_post_size ... which should be > 20M
Correct - it max post is 20M. But I still can't upload more then 2M
If the upload fails, you can also check var_dump($_FILES);
0

if you can not make changes to php.ini then I am afraid you will have to try any jquery based uploaders e.g. valum or blueimp

3 Comments

as he is trying to upload something more than 2M , and php is denying it which can be overcome using these uploaders
but he overwrites the php_value in .htaccess
So there is nothing I can do about it via PHP without access to php.ini? I will look into the jQuery solutions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.