tags:

views:

48

answers:

2

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 is 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

+1  A: 

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.

Snake
in a bincgi folder, and I forgot to write the temp_path variable in, check code again...
Camran
You are right... I looked in the description of the input variables on that same link, and there it says the input should be a path... Check it out, they are very confusing about that... Thanks alot
Camran
A: 

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............

chandru_cp