getimagesize from different document root

images php coding issues or problems here.

Moderators: macek, egami, gesf

hessodreamy
New php-forum User
New php-forum User
Posts: 23
Joined: Thu May 26, 2005 1:58 am

getimagesize from different document root

Postby hessodreamy » Thu May 26, 2005 1:59 am

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
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Thu May 26, 2005 2:17 am

try using ... absolute path...

hessodreamy
New php-forum User
New php-forum User
Posts: 23
Joined: Thu May 26, 2005 1:58 am

Postby hessodreamy » Thu May 26, 2005 2:23 am

How do you mean? AN absolute path from the server root, through to the other document root? How do I do that? I'm not sure.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Thu May 26, 2005 10:05 am

When dealing with paths in PHP, you're dealing with the actual path in the operating system, not the path from the web server's document root. So if the file is in some other document root, use the absolute path to that document root on the filesystem (hint: an absolute path always starts with /).

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Fri May 27, 2005 10:06 am

you may want to go several directories higher your document root: try ../ infront... or the absolute path would work as well..


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest