How to resize an image collected from a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lawillas
Forum Newbie
Posts: 9
Joined: Sat Mar 28, 2009 4:17 pm

How to resize an image collected from a form

Post by lawillas »

Hi....thanks for all the help rendered by you guyz on the last issue i posted....This time i'm trying to create a recruitment portal and i want jobseekers to upload their passport photograph....i'll want to resize the image they upload( regardless of the size ) to my database and after word retrieve it and dispalay it on top of their resume.Will be glad with any help.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to resize an image collected from a form

Post by jaoudestudios »

Here is a image control (resize, rotate etc...) class which should help
http://www.forum.jaoudestudios.com/view ... f=13&t=183
lawillas
Forum Newbie
Posts: 9
Joined: Sat Mar 28, 2009 4:17 pm

Re: How to resize an image collected from a form

Post by lawillas »

I need 1 more thing.....is there an image function that returns to me the extension of the image...like gif or jpeg?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How to resize an image collected from a form

Post by pickle »

Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to resize an image collected from a form

Post by jaoudestudios »

That will get the image size, hence the name. To get the extension you could just take the last . (dot) and everything afterwards.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How to resize an image collected from a form

Post by pickle »

jaoudestudios wrote:That will get the image size, hence the name. To get the extension you could just take the last . (dot) and everything afterwards.
Actually, read the docs. getimagesize() will also get the type of image it is.

Just using the extension is not secure at all. It's trivial to rename MyNastyVirus.exe to MyNastyVirus.jpg.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to resize an image collected from a form

Post by jaoudestudios »

Fair enough, I did not know that it would get the extension too. :)

Yes you are right, it is not secure just to use the extension.
Post Reply