Page 1 of 1

image resize - "open_basedir restriction in effect&

Posted: Wed May 25, 2005 4:20 am
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!

Posted: Wed May 25, 2005 5:24 am
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.

Posted: Thu May 26, 2005 7:59 am
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.