2

What is standard size to upload an image.When user are uploading a large image to my website upload time error is occurring.I am resizing image at the time of uploading also.I want to modify my code as if large image will go to upload then image upload should not occur. So what is standard size of image to upload on server for any website ? So that way i will fix my code. Thanks in advance

Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
Ajay_kumar
  • 41
  • 1
  • 2

2 Answers2

2

php.ini controls file uploads with several configuration directives.

file_uploads controls whether uploading files is allowed. Yes, 1 is the default.

upload_tmp_dir is the temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as. If not specified PHP will use the system's default. The default is NULL.

upload_max_filesize is what you're interested in. It's the largest upload allowed. The default is 2M. If you supply only an integer, it is assumed to be bytes. Or you can change it using a shortcut, like this:

upload_max_filesize = 10M

max_file_uploads is the max number of files that can be uploaded simultaneously. The default is 20.

Another setting that affects uploading files is the max size of POST data which is controlled with post_max_size.

If you do not need / want to change your php.ini file, you can set these values for the duration of your scripts execution using string ini_set ( string $varname , string $newvalue ).

This returns the old value if you succeeded in changing the value, and it returns false if the change didn't succeed. So, to change upload_max_filesize to 10M you could do :

if ( ini_set('upload_max_filesize', '10M') )
{
    // Do stuff that requires big files to be uploaded
}

As a foot note to changing these memory values:

PHP allows shortcuts for bit values, including K (kilo), M (mega) and G (giga). PHP will do the conversions automatically if you use any of these. Be careful not to exceed the 32 bit signed integer limit (if you're using 32bit versions) as it will cause your script to fail.

Peter Ajtai
  • 56,972
  • 13
  • 121
  • 140
0

Most times php is configured to accept no more the 2mb files.

Check here for solution

For the memory problem try:

ini_set("memory_limit","80M"); //or any amount of ram but do not go to high

Your thumbnailer probably uses to much ram because of the high resolution of your image.So giving more memory to php is a quick hack to make it work. But big enough images will still crash.

Community
  • 1
  • 1
Iznogood
  • 12,447
  • 3
  • 26
  • 44
  • I saw 424 kb file (4368 x 2192) file could not resize to thumb size (75x75) and i got an error to error page.What size (standard) i should to fix there ? – Ajay_kumar Aug 17 '10 at 21:22
  • Thats different. Your application needs more ram not because of the file size but because of the resolution. – Iznogood Aug 17 '10 at 21:23
  • Remember that an image will take at least 3bytes per pixel when it's loaded into a truecolor image object. So your 4368x2192 image requires 28,723,968 bytes. If you're using an alpha channel, that's an extra byte per pixel and drives memory up to 38,298,624 bytes. – Marc B Aug 18 '10 at 04:10