Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check and restrict Image sizes

Status
Not open for further replies.

jedel

Programmer
Jan 11, 2003
430
AU
Hi all,

I don't know if I'm using the right search keywords but I cannot seem to find any help for what I want to do.

Basically I have a form where the user can add an image to a database to show in a page.

What I would like to do is stop the user from adding the image if it is over a certain width and height.

I don't want to do any resizing in the process. I want the user to go and edit the image first before they upload it.

My question is how can I check the size of the image and stop the user from uploading it if it is not the right size?

-------------------------------------------------------------
"The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."
 
I don't see a way you can get this to work on the client, unless you can install an ActiveX on each client and invoke this ActiveX using Javascript...

Otherwise, display a message to the client saying "Ensure your images are....." warning them that images over certain sizes will be rejected, then let them upload the image. After the image is uploaded, run the code:

'assume sImagePath holds the full path and name of the image file

Dim oImage, oFSO
SET oFSo = CreateObject("Scripting.FileSystemObject")
IF NOT oFSO.FileExists(sImagePath) THEN
'image file is not found
lWidth = 0
lHeight = 0
ELSE
SET oImage = LoadPicture(sImagePath)
lWidth = ROUND(oImage.Width / 26.4583)
lHeight = ROUND(oImage.Height / 26.4583)
END IF

SET oImage = NOTHING
SET oFSO = NOTHING
 
SimonEireConsulting,

I'm debugging a application that I inherited from another programmer. He is using the LoadPicture() function in the exact same way as in your example.

The problem is that sometimes the name of the image has two periods in it (i.e. "123 North Dr..jpg"). The app seems to be throwing an error because it does not like the double periods.

Have you experienced this problem before? Do you have any advice as for a work-around?

Thanks,

(txmed)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top