开发者

No matter what I do, this PHP function wont find the directory, why?

I have now spent several hours trying to figure this out.

I have this function to take an image on the server,copy it, resize it, and save it in a temporary location.

The function works and i开发者_如何学JAVAs tested inside another php file. But THIS PHP FILE refuse to find the folder '../temp_images' (you can see it in the variable $temp_path).

I have tried all kinds of stuff, adding server root etc...

Does anybody know why this function cant find the path to the directory in this php file, but it can in another php file in the same folder? The function I am referring to is at bottom of the code, imagejpeg();

Here is the function (shortened):

function show_pics($tot_pics, $id_string, $category){

        $ad_id_stripped = end( explode( '_', $id_string ) );
        $img_path="SV/main/ad_images/$category/";
        $temp_path="../temp_images/remove_images/";
        $maxH = 70;
        $maxW = 93;
        $top_offset = 0;
        for ($i=1; $i<=$tot_pics; $i++){

                     $image_p = imagecreatetruecolor($fwidth, $blank_height);
                     $white = imagecolorallocate($image_p, 255, 255, 255);
                     imagefill($image_p, 0, 0, $white);

                     $image = imagecreatefromjpeg('../ad_images/'.$category.'/'.$ad_id_stripped.'_'.$i.'.jpg');

                     imagecopyresampled($image_p, $image, 0, $top_offset, 0, 0, $fwidth, $fheight, $width_orig, $height_orig);

                     imagejpeg($image_p, $temp_path, 100);


        }}

Thanks


Where is this PHP file located? And you don't use $temp_path anywhere in your code? :)

http://be2.php.net/imagejpeg the second parameter should be a filename, not a directory.


This function is used to display random image i.e. at header position of a site. It reads the whole directory and then randomly print the image. I think it may be useful............

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜