You have options, of course.

As David said in his reply -- to do this in PHP, you'll need to get the file onto the server before doing any checking/fixing.

Assuming you're already familiar with php file uploading, you can start here: http://www.php.net/gd -- gd is pretty handy.

Read the docs for gd, and decide how to proceed. The easiest way for you to go is to just enforce some rules on the user. Tell the user that the files must be (for example) jpeg or png, 300 pixels wide by 300 pixels tall. Your form-processing script can inspect the files, and either accept them if they meet requirements, or display an error and tell the user to try again.

However, there's really no reason you shouldn't help the user out. If you want 300x300 images, there's no reason to reject a 600-pixel-square image. You can use the gd functions to scale it down on the server.

Having done this about a dozen times with different rules, I can warn you up front -- give yourself plenty of time to implement this -- and do your best to think through your requirements and how to approach enforcing them before you start to code. There are lots of decisions you'll need to make.

HTH

-Tim
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.

Thanks!

chad

------------------------------------------------------------------------
Need to know the score, the latest news, or you need your HotmailĀ®-get your "fix". Check it out. <http://www.msnmobilefix.com/Default.aspx>
------------------------------------------------------------------------

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to