Handling Large Image Files
Permalink
Hi all. I have several sites that require larger upload limits to be set on the server in order to allow for video and audio file uploads. The problem is that I am constantly having to fix my client's image file sizes. I found a 12,000 x 7000 pixel file they were trying to upload for use as a thumbnail. This causes the server to through a Internal Server Error trying to process the image. Anyway, I wanted to figure out a way to guard against this and came up with this...
I included the zero width check because it seems that some uploads are small enough to upload but too large to give the image a height and width property and as a result defaults to 0.
My question I guess is, is this the best way to do it? Am I missing something?
Thanks in advance.
C
if ( $f && $f->getAttribute('width')!=0 && $f->getAttribute('width')<3200 && $f->getAttribute('height')<3200 ) { //do something }
I included the zero width check because it seems that some uploads are small enough to upload but too large to give the image a height and width property and as a result defaults to 0.
My question I guess is, is this the best way to do it? Am I missing something?
Thanks in advance.
C