Jump to content

Uploading a picture. Any way to validate width before uploading?


suttercain

Recommended Posts

Hi everyone,

 

I am using one of the tutorials to upload images. Because the images go into a template they must be a width of 300 pixels to look good. Is there anyway to validate the width of a .jpg, .png and .gif?

 

I am using this tutorial:

http://www.phpfreaks.com/quickcode/Upload-Multiple-Files-Simple-Code/582.php

 

Thanks for the help!

 

SC

Thanks guys,

 

Is there a way, that I can write a function using getimagesize(), and have a file function delete any image that isn't over 300 width?

 

So a user uploads an image, a function sees that image is not 300px width and deletes the picture right away?

 

That way when they go to use it in the template it's not there. I have a warning before they upload it must be 300 width... but people.... well you know.

 

 

Thanks guys.

 

SC

manual:

 

getimagesize() -> http://ca.php.net/manual/en/function.getimagesize.php

 

unlink (delete function) -> http://ca.php.net/manual/en/function.unlink.php

 

If you check the size of the uploaded image before moving it, it'll stay in the tmp folder and be deleted automatically when the browser session ends.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.