Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

php image upload resize

hi may anyone tell me the image upload resize process ,

for example i want to display a big image using fancybox when clicking thumbnail one, then what should i do when i upload images, just upload the large one but not both thumbnail and large, and do i need to prepare extra files to store the resized image?

1 Answer

Hi Priscilla.

You can upload the big file to your server and then call to timthumb.php

Upload images is easy, the resize action sometimes it's more complicated.

timthumb.php is a small library for resize images.

Using timthumb.php it's easy, just call the file:

<img src="timthumb.php?src=myimage.jpg&w=120&h=180" border="0" />

(BTW... You can rename the .php file)

This script creates a thumbnail with the specified size and save this new file in a cache folder (just create one file per size).

More info about timthumb.php here: http://www.binarymoon.co.uk/2010/08/timthumb/

Hope this helps.