suttercain Posted April 8, 2007 Share Posted April 8, 2007 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 Link to comment https://forums.phpfreaks.com/topic/46077-uploading-a-picture-any-way-to-validate-width-before-uploading/ Share on other sites More sharing options...
trq Posted April 8, 2007 Share Posted April 8, 2007 Is there anyway to validate the width of a .jpg, .png and .gif? Not before uploading. Link to comment https://forums.phpfreaks.com/topic/46077-uploading-a-picture-any-way-to-validate-width-before-uploading/#findComment-223916 Share on other sites More sharing options...
akitchin Posted April 8, 2007 Share Posted April 8, 2007 as for after uploading (but before you store it with PHP), you can use getimagesize(). Link to comment https://forums.phpfreaks.com/topic/46077-uploading-a-picture-any-way-to-validate-width-before-uploading/#findComment-223926 Share on other sites More sharing options...
suttercain Posted April 8, 2007 Author Share Posted April 8, 2007 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 Link to comment https://forums.phpfreaks.com/topic/46077-uploading-a-picture-any-way-to-validate-width-before-uploading/#findComment-223928 Share on other sites More sharing options...
AndyB Posted April 8, 2007 Share Posted April 8, 2007 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. Link to comment https://forums.phpfreaks.com/topic/46077-uploading-a-picture-any-way-to-validate-width-before-uploading/#findComment-223931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.