php get image height without the use of input box?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lehula
Forum Newbie
Posts: 7
Joined: Sat Jul 14, 2007 4:33 pm

php get image height without the use of input box?

Post by lehula »

I'm looking around and it looks like there is lots of good info on pulling a var from php and using it in javascript, but no the other way around. All the info I can find says to just use hidden input boxes to hold the data, then post them with a submit button. But I have like 40 images, and I want to store their 'left' 'top' width' height'. Thats a lot of hidden input boxes to write (160+). It would be nice not to have those html'd into my script. Is there anyway to get the image height and set it as php data without a input box?

Example:

NOT THIS ----->

<form method="post">
<input style="display:none" name="some image height">
<input submit>
</form>

--------------------------------------------------------------------
THIS ------->

document.getElementById("some image").height = $post_imageheight[];


I'm not sure if I explained this clearly enough. Let me know if you need more detail. thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There are many ways to transmit data from a page to PHP... Cookies, URL, are form submission are the primary means; all of which can be built my Javascript. I'm not sure I understand why Javascript needs to do this however.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

this could easily be done in php

run this

Code: Select all

print_r(getimagesize($your_image));
Index 0 = width, Index 1 = height. It even contains a string to use in your HTML.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
lehula
Forum Newbie
Posts: 7
Joined: Sat Jul 14, 2007 4:33 pm

Post by lehula »

HOLY CRAP, I DIDN'T KNOW ABOUT GETIMAGE SIZE. THANKS
Post Reply