Forum Moderators: coopster

Message Too Old, No Replies

Php script works local but not on the server.

         

guille

12:41 am on Apr 30, 2007 (gmt 0)

10+ Year Member



I found a script to display a simple photo gallery with dynamic thumbnails. I modified the script to make it save the photo thumbnails. It works perfect here in my computer but when i upload to my hosting it doensīt seem to work.

Here the script:

function draw_image($src) {
global $size;
list($width, $height, $type, $attr) = getimagesize($src);

if($size == 'full') {
$img = imagecreatefromstring(file_get_contents($src));
} else {

if(file_exists(stripslashes(PATHT.$_REQUEST['src']))){
imagedestroy($img);
$img=imagecreatefromjpeg(urldecode(stripslashes(PATHT.$_REQUEST['src'])));
} else {
$img = imagecreatefromstring(file_get_contents($src));
$lowest = min(THMBWIDTH / $width, THMBHEIGHT / $height);
if($lowest < 1) {
$smallwidth = floor($lowest*$width);
$smallheight = floor($lowest*$height);
$tmp = imagecreatetruecolor($smallwidth, $smallheight);
imagecopyresized($tmp, $img, 0, 0, 0, 0, $smallwidth, $smallheight, $width, $height);
imagedestroy($img);
$img = $tmp;

$file = urldecode(stripslashes(PATHT.$_REQUEST['src']));
imagejpeg($img,$file);
}
}

}

mostrar($type,$img);
imagedestroy($img);

I'd appreciate any feedback ...totally lost here...

jatar_k

12:49 am on Apr 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



do you get errors?

can you explain "doesn't work" a little better?

and a word of advice, don't use $_REQUEST, it is a security concern, specify $_POST or $_GET

you should never use $_REQUEST

guille

4:04 am on Apr 30, 2007 (gmt 0)

10+ Year Member



The script doesnīt return anything... no images.
I think the problem is here:"if(file_exists(stripslashes(PATHT.$_REQUEST['src'])))".
I donīt get any error mesage, just the images not drawing.

Now i will take a look at Post and Get.. to find how to use them (iam a programmer but new to php).

Thanks in advance.

jatar_k

11:44 am on Apr 30, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't see where that is supposed to be coming from, you would think it is supposed to be a constant, though I don't see it being set.

hmmm, maybe try changing all occurences of PATHT.$_REQUEST['src'] with $src as $src seems to be the image path

I think you have display_errors [php.net] turned off in your php.ini as well because that should be giving you a parse error. It also may just be that error_reporting [php.net] is set too low.

omoutop

12:27 pm on Apr 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You may also want to look at the permissions of the folder where you save the images.

Also, do you have the same php version in your pc as in your server? Can you check for differences? Many new image scripts use the php5 functions, while most servers are at 4.x.

guille

4:34 am on May 1, 2007 (gmt 0)

10+ Year Member



here i post all the complete code....

<snip>

Please take a look... iam stuck.... =(

Thanks in advance.

[edited by: dreamcatcher at 7:17 am (utc) on May 1, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]

londrum

9:39 pm on May 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



try inserting a little line which will make it print out the images's URL onto the page. then you can at least see if the URL is pointing to the right place. if it's stripping out the slashes from the URL then you will be able to see.