Reputation: 1731
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
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
Reputation: 447
Pathinfo should do the trick for you. http://php.net/manual/en/function.pathinfo.php
Upvotes: 0