i have the following code:
$filename = $this->getMsisdn().".png";
if (!file_exists(sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename))
{
$filename = "Rainbow-code-1_blck.jpg";
//rename it to msisdn

 $source = imagecreatefromjpeg($filename);

}

i JUST want to rename "Rainbow-code-1_blck.jpg" to $this->getMsisdn().".jpg" ??
is this possible?? i want to have the SAME picture but it has a different name

please help?
thank you

    Please use [noparse]

    ...

    [/noparse] tags around your code excerpts, which I have added here -- MOD[/color][/i]

    my rename is not working i have now:

    $filename = $this->getMsisdn().".png"; 
    if (!file_exists(sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename)) 
                {  
    $file_in = "Rainbow-code-1_blck.jpg"; $using_default_pic = 1;
    } if ($using_default_pic == 1) { $using_default_pic = 0; echo "filename before rename ".$file_in; $filename = rename($file_in,$this->getMsisdn()."jpg"); echo "calling resize image after rename: ".$filename.'<br />'; } echo file_in gives:Rainbow-code-1_blck.jpg

    and echo "calling resize image after rename: ".$filename.'<br />'; gives nothing????
    please help?
    thank you

      [man]rename/man returns boolean true/false depending on its success, not the file name. You can check that to see if the rename worked. (For debugging you may want to enable error messages if not already so that you can see if there are any permission errors or such.)

        so when i echo $filename i get nothing thus the rename did not work? why would that be? can you please help me with this and show me how?
        one the rename works i can just see if file_exists and carry on from there

        thank you

          Stick this at the top of the script to see if any error messages are displayed:

          <?php
          ini_set('display_errors', true); // change to false for production version
          error_reporting(E_ALL);
          
          /* ...rest of script... */
          ?>
          

          Most likely problems are that either there is a typo and the original file does not exist, or else it is there but the file/directory permissions do not allow PHP to change it (remember that in many web host configurations the PHP scripts are executed by the Apache user account, not your personal user account).

            thank you very much..i sorted it out.. 🙂

              Write a Reply...