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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading uploaded file

Status
Not open for further replies.

Silvano

Programmer
Jul 16, 2001
386
US
Situation:
- I am programming an application in ColdFusion, where user have the possibility to upload a file; the file is image file (gif, jpg, png)

Problem I have:
- I need to know the width and the height of the uploaded image

Is there a function that can return those data?
 
Hi sylvano,

Don't believe there is such a function. What you could do is the following:

First, you write a hidden layer containing the image.
Code:
<div id=&quot;hiddenImage&quot; style=&quot;position:absolute;visibility:hidden&quot;>
	<img src=&quot;#image1#&quot; name=&quot;img1&quot;>
</div>

Then you call this script at onload:

Code:
<script language=&quot;JavaScript&quot;>
	if (parseInt(navigator.appVersion) >= 4) {
		if (navigator.appName == &quot;Netscape&quot;) {isNav = true;}
		else {isNav = false;}
	}

	function getDim() {
		if (!isNav) {
			img = document.all('hiddenImage');
		} else {
			img = document.layers['hiddenImage'];
		}
		w = img.document.images['img1'].width;
		h = document.images['img1'].height;
	}
</script>

Gtz,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top