0

I'm working on the avatar upload on my website and would like for users to be able to input an image using URL's.

How would I go about taking the image from the URL supplied in the form and checking its file format (.png, .jpg, .gif), file size (50kb max), and file dimension(100x100 max)?

MrSmith42
  • 9,961
  • 6
  • 38
  • 49
Cory
  • 732
  • 3
  • 7
  • 22
  • 1
    first use the search function :). See: http://stackoverflow.com/questions/724391/save-image-from-php-url-using-php. – Tim Nov 10 '10 at 19:36

1 Answers1

3

You can retrieve the file with cURL, file_get_contents, copy, or sockets (fsockopen). Once you have it, checking the file format, file size and file dimensions are the same as the code you wrote to do it from local uploads.

http://php.net/manual/en/function.getimagesize.php

http://php.net/manual/en/function.filesize.php

http://us2.php.net/manual/en/function.finfo-file.php

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101