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

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

So you have completed the file upload tutorial. The tutorial has taught you how to upload an image using a form, and then it auto makes a thumbnail and shows it to you, nice. Now lets say you are on a public computer, and can’t save to the desktop or whatever. So you would like to upload a photo that is already on the internet, but thumbnail it to your webserver. We need to be able to allow our users the ability to submit a link to an image and work from there.

Take a look at the demo before jumping in:
Demo Here

What you will need is a decent webserver, PHP with cURL enabled (check in your phpinfo();) and time. Please note that within php you are unable to test for MIME types unless you brute force them, which is beyond the scope of this tutorial. You can however add extensions to PHP to enable access to the mime types of stored files on the server, please take a look here for more information. But for this tutorial we will examine the file extensions in the url and go from there.

So you have completed the file upload tutorial. The tutorial has taught you how to upload an image using a form, and then it auto makes a thumbnail and shows it to you, nice. Now lets say you are on a public computer, and can’t save to the desktop or whatever. So you would like to upload a photo that is already on the internet, but thumbnail it to your webserver. We need to be able to allow our users the ability to submit a link to an image and work from there.

Take a look at the demo before jumping in:
Demo Here

What you will need is a decent webserver, PHP with cURL enabled (check in your phpinfo();) and time. Please note that within php you are unable to test for MIME types unless you brute force them, which is beyond the scope of this tutorial. You can however add extensions to PHP to enable access to the mime types of stored files on the server, please take a look here for more information. But for this tutorial we will examine the file extensions in the url and go from there.

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