i hasve the following code:

$filename = "Rainbow-code-1_blck.jpg";
if (file_exists(sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename))
{
    echo "file found";
     $source = imagecreatefromjpeg($filename);
}

but i get the following warning:
Warning: imagecreatefromjpeg(Rainbow-code-1_blck.jpg): failed to open stream: No such file or directory in /home/helloises/traffic_2/phoenix/plugins/rainbowCodePlugin/lib/model/RcProfileTable.php on line 168

i dont understand my file does exist...it goes in to the if cos the echo executes
please help i am new to this and have no idea how to fix this
thank you

    oops sorry posted in wrong place it needs to go into the newbies thead please

      helloise wrote:

      i dont understand my file does exist...it goes in to the if cos the echo executes

      Your if() statement checks to see if there is a file located at:

      sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename

      exists. However, you then attempt to load the file located at:

      $filename

      which, from the error message, clearly does not exist.

        thank you i took out the if and echo and only have now:
        $filename = "Rainbow-code-1_blck.jpg";

        $source = imagecreatefromjpeg($filename); ///line 166

        and still get the same warning:
        Warning: imagecreatefromjpeg(Rainbow-code-1_blck.jpg): failed to open stream: No such file or directory in /home/helloises/traffic_2/phoenix/plugins/rainbowCodePlugin/lib/model/RcProfileTable.php on line 166

        sorry for my ignorance but i dont understand
        please help
        thank you

          Why did you remove the if() statement? Surely you would want to check that the file exists before attempting to use it...

          As for the problem, do you not see the huge discrepancy between the file path that works and the one that doesn't in my post above? In the one that works, you have a full path in front of $filename, whereas you later then attempt to access the file with just $filename.

            Write a Reply...