-3

I want to make an image upload API Example:http://mysite.com/api.php?url=http://test.com/1.jpg How to write a script can get the image URL from the URL? Also check.the extension of the image Then upload to my site and redirect to the image. Thanks.

1 Answers1

0

Have api.php run a cURL command on your server to get the URL of the file submitted to your API then download the file where you want. Have it then return the location of the image to your script for final processing to include renaming and any database storage you want to accomplish.

rws907
  • 787
  • 4
  • 14
  • 25
  • Can i do this without db&curl? – user1727651 Oct 08 '12 at 03:31
  • If you can that would be news to me. You would need cURL to process the image fetch - or maybe use exec() and wget. I have never tried the latter but give it a shot. Why wouldn't you want to store the image information in the database? There seems to be a lot of information you could collect for analysis and reporting later. – rws907 Oct 08 '12 at 03:42
  • In PHP file can be read over the network into a string with file_get_contents function, no need for cURL or wget. http://php.net/manual/en/function.file-get-contents.php – divanov Oct 10 '12 at 10:03
  • True... I guess this StackOverflow article makes it as easy at it can be... http://stackoverflow.com/questions/724391/saving-image-from-php-url-using-php – rws907 Oct 10 '12 at 21:13