getimagesize from different document root

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
hessodreamy
Forum Commoner
Posts: 58
Joined: Wed Apr 20, 2005 8:11 am

getimagesize from different document root

Post by hessodreamy »

The website I am working on uses getimagesize to rescale images.
We're setting up a new site using the same images, but am having trouble getting the image size. I think its because of the images being in a different document root to the script, though it displays the image fine.

We're getting the image size like so:

Code: Select all

list($width, $height, $type, $whstr) = getimagesize('../../~gan1/images/summarypics/2211.jpg');
This function returns false, and the error message:

Code: Select all

Warning: getimagesize(../../~gan1/images/summarypics/2211.jpg): failed to open stream: No such file or directory
Though, like I said, the image then displays, completely oblivious to the troble its causing me.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Please take the time to post in the correct section :roll:
hessodreamy
Forum Commoner
Posts: 58
Joined: Wed Apr 20, 2005 8:11 am

Post by hessodreamy »

Which section should I Post in? This section is regarding coding. The 'general discussion' section didnt seem relevant.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

hessodreamy wrote:Which section should I Post in? This section is regarding coding. The 'general discussion' section didnt seem relevant.

uhhh if the gerneral discussion section did not seam relevant than why did you post it there first?

ok no lectures, so the only problem your having is the error popping up? well you can always

Code: Select all

error_reporting(E-NONE);
but that is not a very wise idea but if its just the error thats showing up while the function seams to work then why not?
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

Edit: Got mixed up between server path and browser path.
Last edited by Bennettman on Thu May 26, 2005 1:23 pm, edited 2 times in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Actually, I know you can go outside the document root. Try using an absolute path rather than a relative one (use "/home/gan/images[and so on]"). This also makes the code work regardless of where it is on your server.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply