Jhon Woodwrick
Jhon Woodwrick

Reputation: 1113

checking an image for size in php?

i want to check an images size thats already uploaded to the server: psuedocode

if (checksize($image) >10mb {

die

}

can i do something like that in php? thanks :)_)

Upvotes: 0

Views: 135

Answers (2)

brettkelly
brettkelly

Reputation: 28205

Assuming $image is a path to a file somewhere on the filesystem:

if(filesize($image) > (10 * 1024 * 1024)){  // is it larger than 10mb?
   die('too big');
}

Upvotes: 2

Daniel A. White
Daniel A. White

Reputation: 190907

Here is the PHP documentation.

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

Upvotes: 1

Related Questions