#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    10
    Rep Power
    0
    Hi everybody,

    I have the following problem, I have a database (MySQL) in which I can store filenames, in my script I can select a file from my hard drive that will be uploaded and stored in a directory on the server. So far so good.

    Now when I want to replace the file by another one and use the same script it won't replace the file. Does anybody outthere know what the problem might be??

    The following code is my part of the script that does the uploading:

    if ($img1_name != "") {

    copy("$img1", "/home/sitename/www/dbasepictures/$img1_name") or die ("Couldn't copy the file!");

    } else {

    die("No input file specified");
    }


    Thanks a lot in advance!!

    peace,

    cube
  2. #2
  3. No Profile Picture
    Carpe Diem
    Guest
    Devshed Newbie (0 - 499 posts)
    Try unlinking it first something like
    if(file_exists("filename"))
    {
    unlink("filename")
    }

    should do the trick (Or code to that effect), also don't forget that the chances are the file is owned by the web server user (nobody ot httpd normally) so check permissions etc....

    The user wont be able to remove a file that is owned by someone else



    ------------------

    Regards
    Darren
    --
    http://www.php4hosting.com/ $
    http://www.php4hosting.co.uk/ £
    PHP/MySQL Enabled Hosting/Dedicated Servers

Similar Threads

  1. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 09:27 AM
  2. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 07:06 AM
  3. Replies: 1
    Last Post: February 8th, 2004, 02:59 PM
  4. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 08:42 PM
  5. Simple find and replace word search for a text file with php?
    By rabid lemming in forum PHP Development
    Replies: 4
    Last Post: February 1st, 2004, 10:37 PM

IMN logo majestic logo threadwatch logo seochat tools logo