SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rename() problem ???

    hello guys

    I'm trying to move some pics from a folder called /tmp to a folder called /photos.

    I've stored the image filename in:
    $_SESSION['pic1']

    The code i'm using is the following:
    rename("tmp/".$_SESSION['pic1']."", "photos/".$_SESSION['pic1']."");

    but i get the following error:
    Warning: rename(tmp/,photos/) [function.rename]: File exists in C:\wamp\www\site.com\v3\control.php on line 69

    When i alter my code and instead of the SESSION variable i use the actual filename.jpg, everything works smoothly!

    Any clue???

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    notice that the warning does not include your filename? i think your session variable isn't set. have you tried echo'ing $_SESSION['pic1'] to see if it's set?

    also, why do you have the ."" after the session variable?

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The problem is obviously that the session variable isn't being set. Are you sure you're setting the session variable correctly? Perhaps you've forgotten to do session_start() at the top of the page?

    Also, why are you concatenating an empty string after the session variable? There is no point.
    PHP Code:
     rename("tmp/".$_SESSION['pic1']."""photos/".$_SESSION['pic1'].""); 
    is identical to
    PHP Code:
     rename("tmp/".$_SESSION['pic1'], "photos/".$_SESSION['pic1']); 

  4. #4
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    absolutely correct my friends!

    though i had set session_start(), i hadn't refreshed my page so as for the session to start correctly....

    once again thank you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •