I know it's been a while since you posted this, but I came across an answer for you.
First, go to
http://webnet77.com/scripts/list-modules/ and download the free script there. (The download link is at the bottom of the page.) Unzip the file. Upload list-modules.pl to your cgi-bin (or wherever you put executable perl scripts). Be sure you upload in ASCII mode. CHMOD the file to 755. Then run it. You'll get a list of all of the modules that are installed on your server, in three columns, listed alphabetically. The one you want to look for is
Image::Size.
If you have that module you're all set. If not, let me know what, if any, Image modules there are and I'll see if I can work with them. For the rest of this, I'm going to assume that you have Image::Size available to you.
In db.cgi, after
$db_script_path = ".";
add
(If you don't have the Image::Size module on your server, it's likely that your script will crash just by having that line in there.)
In your .cfg file, where you have your other file upload parameters, add
Code:
$max_width = 400;
$max_height = 200;
Use whatever numbers you want. Don't make the numbers 0, though. If you don't want to put a limit on either the height or the width, make it some huge number like 5000. You also might want to put a notation in sub html_record_form about the maximum size that is acceptable so your users don't get a nasty surprise.
Back in db.cgi, sub validate_upload, towards the end, after
chmod (0666, "$SAVE_DIRECTORY\/$filename");
Code:
($img_height,$img_width) = imgsize("$SAVE_DIRECTORY\/$filename");
if (($img_height>$max_height) or ($img_width>$max_width)) {
unlink "$SAVE_DIRECTORY\/$filename";
return "Your image is too large. Your image is
$img_height tall and $img_width wide. We can only
accept files that are $max_height tall and
$max_width wide. Your image was not saved."
}
If you want to use the size in the image tag when you print it out the image, make the following change in html.pl, sub html_record:
Code:
$size = html_imagesize("$SAVE_DIRECTORY\/$filename"); print qq|<img src= "$SAVE_DIRECTORY_URL/$file
$size">|;
I haven't tested it out yet. I wanted to give you the info first. I'm going to go give it a try and see what errors I've made. :-)
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.