image resize - "open_basedir restriction in effect&

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
thurstan
Forum Commoner
Posts: 28
Joined: Mon Feb 28, 2005 7:40 am

image resize - "open_basedir restriction in effect&

Post by thurstan »

hello. i am trying to modify a news script that allows uploading images to automatically resize the images. here's the code i have:

the images:

Code: Select all

$picture = $result[0]["picture"];
$picturepath = "/***/*******/photo/";
the image call:

Code: Select all

if (!empty($picture)){
print "<div><img src=\"$picturepath$picture\" alt=\"$title\"></div>";
the modification for auto resize:

Code: Select all

if (!empty($picture)){

function imageResize($picture, $target, $alt=NULL) {

$theimage = getimagesize($picture);
$width = $theimage[0];
$height = $theimage[1];

if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}

$width = round($width * $percentage);
$height = round($height * $percentage);

echo "<img src=\"$picturepath$picture\" width=\"$width\" height=\"$height\" alt=\"$alt\">";
}

imageResize("$picturepath$picture", 50, "alt");
i keep getting the following error message and am kind of stuck as to why:

Warning: getimagesize(): open_basedir restriction in effect. File(/****/******/photo/1115200293CAM_CommAppMedia.jpg) is not within the allowed path(s): (/home/httpd/vhosts/********/httpdocs:/tmp) in /home/httpd/vhosts/*********/httpdocs/*****/*******/news.php on line 43

any pointers would be very helpful. thanks alot!
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

It's nothing to do with the script. open_basedir() restriction is a security measure to make sure you're only accessing parts of the filesystem on the server that you're supposed to. If this is a local issue on your computer, read the docs and find out the solution (I don't know it). If it's online, talk to your hosting company. Mine, clook.net, have open_basedir() restriction set up so scripts can only run if they're accessed from the domain name.. annoying, but quite sensible really.
thurstan
Forum Commoner
Posts: 28
Joined: Mon Feb 28, 2005 7:40 am

Post by thurstan »

thanks for the reply.

ok so it seems i can't do anything about the external seetings, so i need to fit another piece of code into here.

i've searched this entire site for a resize image solution, but just can't work out how to fit into my code, does anybody have a suggestion for a piece of resize code that would fit inot the above?

thanks.
Post Reply