function call works, but not really

images php coding issues or problems here.

Moderators: macek, egami, gesf

wickedsid
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Oct 09, 2010 12:54 pm

function call works, but not really

Postby wickedsid » Sat Oct 09, 2010 1:06 pm

hello
I'm new here, but I don't consider myself as a n00b in PHP :) a dare call from myself but I created several websites already with some hard code and cool stuff (at least, I think it's cool :))
But with this problem I really look like a total L*ser and newbie.
but help would be appreciated :)

so, what's the problem. I created 3 pages. the first page, people are asked to enter a name for a project. and click next. in PHP I create a folder with that specific name (0777 permissions --> looks stupid, but read on)
in the next page I have a javascript/flash window to upload pictures to a temp-folder on the server.
when they click next, my problems appears.

the meaning of the 3th page is:
1. copy the images (yes, several images) from the temp folder to the folder created in step 1.
2. use GD-library to draw a nice border around the images.
3.rename the images and update my DB with these names for use later on in my site.

but when I click next. the images are copied to the new folder. BUT the border will not be drawn around it!!
I use next code to call the "draw-function":

Code: Select all

$dir = "../project_images/".$prj_naam;
   if (is_dir($dir)) {
          if ($dh = opendir($dir)) {
              while (($file = readdir($dh)) !== false) {
                  if($file!="." && $file!=".."){
                      resize($file); --> function from other php-page
         }                       
                     }
           closedir($dh);
          }
   }


function RESIZE is :

Code: Select all

<?php
function resize($add){
   //$add= $foto_nm;
   //$add2="1.jpg"; // Remove comment if a new image is to be created
   //1e zwarte lijn---------------------------------------------
   
   $border=1; // Change the value to adjust width
   $im=ImageCreateFromJpeg($add);
   $width=ImageSx($im);
   $height=ImageSy($im);
//        ....... MORE CODE COMES HERE, BUT IT'S TOO MUCH!!
   echo "photo: $add resized";
   echo "<img src=$add></img>";---> with this line the borders are actually drawn and I see them on my screen WITHOUT the picture in it.
}
   ?>


at first I thought it was a problem with permissions (0777) but that didn't solve it!!
very weird!!
so, call me a n00b but I can't seem to find the error.

thanks already!!!!

wickedsid
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Oct 09, 2010 12:54 pm

Re: function call works, but not really

Postby wickedsid » Sat Oct 09, 2010 10:46 pm

found it!!
indeed a n00b error I guess.

I altered the function call:

Code: Select all

   $dir = "../project_images/".$prj_name;
   if (is_dir($dir)) {
       if ($dh = opendir($dir)) {
           while (($file = readdir($dh)) !== false) {
               if($file!="." && $file!=".."){
                  resize($file,$prj_name);   
               }                       
           }
           closedir($dh);
   }
}


and the function itself:

Code: Select all

function resize($file,$prj){
   $dir = "../project_images/".$prj;
   $add=$dir."/".$file;
   

Thanks guyz, and girlz!! :-)


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest

cron