doubledee Posted February 21, 2012 Share Posted February 21, 2012 Do I need to check both the "Image Size" AND "Image Dimensions" for files that Users upload to my website? Currently I have... // ******************** // Check File-Size. * // ******************** if (empty($errors)){ // Check File-Size in Bytes. if (filesize($tempFile)<4000){ // File too small. $errors['upload'] = 'File-size must be greater than 4 Kilobytes.'; }elseif (filesize($tempFile)>100000){ // File too big. $errors['upload'] = 'File-size must be less than 100 Kilobytes.'; }else{ // File-Size Okay. // Continue Processing Upload... } }//End of CHECK FILE-SIZE I guess I haven't been worrying about "File Dimensions" because I resize everything here... // ********************** // Set New Dimensions. * // ********************** // Capture Dimensions on Original Image. $origWidth = imageSX($origImage); $origHeight = imageSY($origImage); if ($origWidth > $origHeight){ $newWidth = 100; $multiplier = $newWidth/$origWidth; $newHeight = $origHeight * $multiplier; } if ($origWidth < $origHeight){ $newHeight = 100; $multiplier = $newHeight/$origHeight; $newWidth = $origWidth * $multiplier; } if ($origWidth == $origHeight){ $newWidth = 100; $newHeight = 100; } Thanks, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/257482-regulate-image-size-and-image-dimensions/ Share on other sites More sharing options...
kicken Posted February 21, 2012 Share Posted February 21, 2012 Do I need to check both the "Image Size" AND "Image Dimensions" for files that Users upload to my website? Only if you feel it necessary. If your only going to use resized copies and not the original anywhere than dimensions is less of a concern probably as you'll have them standardized. Even if you do use the original, checking dimensions is only necessary if you feel it to be. For example if you had a photo gallery people may want/need to upload large dimension images. Pretty much, it all boils down to do you think it is necessary, and if so what do you feel is a reasonable dimension/size for user's images. I personally haven't limited peoples image uploads beyond raw filesize in anything I have done recently. Even if it's just for a profile photo or similar i usually give the user the ability to crop/edit their upload as necessary so I store the original un-altered file somewhere then make copies to use on the site where necessary. Quote Link to comment https://forums.phpfreaks.com/topic/257482-regulate-image-size-and-image-dimensions/#findComment-1319719 Share on other sites More sharing options...
doubledee Posted February 21, 2012 Author Share Posted February 21, 2012 Okay, thanks Kicken! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/257482-regulate-image-size-and-image-dimensions/#findComment-1319728 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.