Hat
Hat

Reputation: 1731

get image data uploaded from url

I'm trying to write a form where a user can upload an image from a url. I know how to upload the image using fopen and fwrite, but I have no idea how to get/check other information about the file such as the filesize, mime type, file extension etc before the file has actually been uploaded. Is this even possible?

Upvotes: 0

Views: 256

Answers (2)

Chris Ostmo
Chris Ostmo

Reputation: 1232

There are at least a couple of methods, but the simplest one that will give you everything you specifically mention is getimagesize()

$info = getimagesize( 'image.png' );
print_r( $info );

pathinfo() won't give you the MIME type.

Upvotes: 1

Johan Sundén
Johan Sundén

Reputation: 447

Pathinfo should do the trick for you. http://php.net/manual/en/function.pathinfo.php

Upvotes: 0

Related Questions