santa
santa

Reputation: 12512

quick file size check with PHP

Is there a way to run a quick check what is the size of a file to be uploaded? I use a class that does it but I have to wait until it runs entirely before I can get that info. I would like to be able to skip going through the class if the file is larger, than say 5MB, i.e. don't even need it exactly if it is larger than max specified.

Thanks.

Upvotes: 0

Views: 879

Answers (3)

KJYe.Name
KJYe.Name

Reputation: 17169

you can achieve this by using JavaScript/Mootools with flash.

Here is a plugin that does exactly that.

Fancyupload

Fancyupload Demo w/ image file upload

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157839

you call it "uploaded" and misguide many people.

while you want to know filesize before upload.

but before file gets entirely uploaded, PHP isn't involved at all

Upvotes: 0

JasonWoof
JasonWoof

Reputation: 4196

Yep. There's a variable in the $FILES tree called "size" see details here:

http://www.php.net/manual/en/features.file-upload.post-method.php

Edit: also, you can set a max upload file size. You can set what php will accept, and put a hidden field in the html form to tell the browser what the max is (hopefully some browsers will do something intelligent with this.)

Upvotes: 1

Related Questions