Tutorial: How to make an Image Upload and Thumbnailer Script with cURL

Tutorial: How to make an Image Upload and Thumbnailer Script with cURL

First let me tell you a little about what will happen here. PHP has an extension called cURL, standing for client URLS. It allows our webserver to browse other files on the internet, in turn it makes web requests just like our browsers do. The power of cURL however is that it allows us to save and manipulate the information that comes back.

You might want to use cURL to target areas on a website you visit frequent, or setup cron jobs that will email you when a website’s content changes. In our case we will use it to grab an image from a website out in internetland bring it back, save it to a temporary folder, thumbnail it, delete the original image (off our server of course) and then show it! How great PHP is. Also for your idea pool is RSS with cURL ;)

1. What you will firstly need to do is copy the thumb.php file into a new file, rename it to thumbcurl.php interesting name i know. If you haven’t done the previous part to this tutorial you can get the file from: thumbstutorial.zip but i recommend that you do the tutorial here.

2. Next open up your thumbcurl.php file and get ready to do some editing. The first thing you will want to do is add the extra input field to the HTML form so that people can enter in their url. My form now looks like:

File: or File URL: Max Dimensions: (optional)

Make sure yours does too!

Posted by VoiDeT

Categorised under PHP
Bookmark the permalink or leave a trackback.

3 Comments

  1. Hi … thnx 4 great script :D

    August 17, 2008 @ 6:44 am
  2. Havent watched your code, I’ve tried the demo though. Extensions like JPG, PNG, GIF and all other uppercases, are not accepted. You should use uclower on the relative image path to get it all lower case before you perform the extension check.

    August 20, 2009 @ 5:27 am
  3. VoiDeT

    Hi Sebastian.

    Not too sure what you’re talking about here.
    The uppercased filenames are working fine.
    There is no such function uclower also.

    Take a look at this line:
    $filetype = strtolower(strrchr($_POST['srcurl'], ‘.’));

    That lowers the file name.

    August 20, 2009 @ 8:55 am

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

or