开发者

Is there a way for php or ajax to get image size in bytes or kb or mb right away?

开发者 https://www.devze.com 2023-01-14 23:21 出处:网络
I have a nice php and ajax script that uploads a photo and displays the image after uploading. I also have rules that it must follow too.

I have a nice php and ajax script that uploads a photo and displays the image after uploading. I also have rules that it must follow too.

But my pro开发者_StackOverflowblem is the maxSize is 2mb, and right now when you choose an image and you start to upload it -- it basically looks at the whole upload (which can take a while) and then it tells you if there is a problem.... Even if the image or picture is 10mb file, it will process this for minutes and minutes and then it will error out and say "File size too big"

My question : Is there a way with ajax or php (i know there is with flash) -- to tell right away if the file size is too big?? So, if I have a 8mb picture I want to upload, it will error out right away that the file size is too big, instead of trying to upload and process this...

Hope that makes sense!!

Thanks


Frustratingly, no. You'd have to use something like flash or java. Keep in mind, this would be for convenience only - you'd still need to check on the server because anything on the browser could be faked or bypassed.

0

精彩评论

暂无评论...
验证码 换一张
取 消