Results 1 to 2 of 2

Thread: Server Setting or Typo?

  1. #1
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default Server Setting or Typo?

    My code is being executed here "/public_html/rename.php" with this

    PHP Code:
    rename("products/$dir/$value""products/$dir/$submitted");
    rename("products/$dir/tmb/$value""products/$dir/tmb/$submitted"); 
    my error message is

    rename(products/Helmets/H200_LP1.jpg,products/Helmets/H200_LP1.jpg) [function.rename]: No such file or directory in /home/theleat1/public_html/rename.php on line 11
    this part
    (products/Helmets/H200_LP1.jpg,products/Helmets/H200_LP1.jpg)
    Makes me think the server may be parsing the rename incorrectly because there is a space there.

    The figures are located in /public_html/products/Helmets and /public_html/products/Helmets/tmb.

    my full code is:

    PHP Code:
    <?php
    session_start
    ();
    $_SESSION['logged_in'] = "yes";
    $dir $_GET['dir'];
    foreach(
    $_POST as $submitted) {
        
    $value key($_POST);
        
    $unset_value key($_POST);
        
    $value preg_replace('/(.*?)_jpg/'"$1.jpg"$value);
        echo 
    "original= products/$dir/$value.  " newname= products/$dir/$submitted<br />";
        echo 
    "original= products/$dir/tmb/$value.  " newname= products/$dir/tmb/$submitted<br />";
        
    rename("products/$dir/$value""products/$dir/$submitted");
        
    rename("products/$dir/tmb/$value""products/$dir/tmb/$submitted");
        unset(
    $_POST[$unset_value]);
    }
    ?>
    On another side question does $_POST change . to underscores when it is inputted as the key for example figure1.jpg become figure1_jpg. Thanks.
    Last edited by bluewalrus; 12-20-2010 at 04:21 AM.
    Corrections to my coding/thoughts welcome.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    the space is missing in the error message because it's optional (PHP ignores it anyway).

    Two things to check:
    1) use absolute filepaths instead of relative ones - e.g., try $_SERVER['DOCUMENT_ROOT'].'/products/'.$dir.'/'.$value.

    2) make sure the directory exists, and that the path to it is correct (I know that's obvious, but it's the problem nine times out of ten) and that your script has read/write permissions for every directory in the path.

  3. The Following User Says Thank You to traq For This Useful Post:

    bluewalrus (12-20-2010)

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
  •