Sponsor
Now Playing
- Alix Perez – I'm Free 3 hours ago
- Alix Perez – Intersections 3 hours ago
- Alix Perez – Forsaken 3 hours ago
- Glen E Ston – Ouroboros (Original Mix) 4 hours ago
- Black Sun Empire – Everything 4 hours ago
Tutorial: How to make an Image Upload and Thumbnailer Script with cURL
April 8, 2008,
7,169 views
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.
3 Comments
Hi … thnx 4 great script
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.
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.