[nycphp-talk] a question about uploading pictures
ramons at gmx.net
Sun Mar 16 18:06:10 EDT 2008
chad qian wrote:
> I will let user upload 3 pictures to the backend database first.Then
> these 3 pictures will be displayed on the web page later.
> My question is:
> Do I have to setup rules about uploading pictures,like the size,the
> pixels?I want these 3 pictures to be the same format(size,pixels..) when
> displayed on internet.So do I need to tell user how pictures should be
> when they do upload or I program php to change the properties of
> pictures?Of course,pictures must be visable,not too big or too small, on
> the web page.
No, picture uploads work the same as any other file uploads and you cannot
dictate image type, size, pixel depth, or such on the client side using PHP.
PHP is server side only and by the time PHP has a chance to get hold of the
image file it is already uploaded.
There are a few checks you can put into place, such as checking for the exif
headers in jpegs or checking for the magic number, which tells you of what
type the file is. I once asked about this a long time ago and examples were
given by fellow NYPHPlers, so you want to search for that in the archives. I
never got around to implement this, but it is not forgotten.
Flash, which is both client side code and may accept or reject an image file
More information about the talk