#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    98
    Rep Power
    2

    Image replacement, with move_uploaded_file


    Hi All,

    I'm having trouble with some code.

    PHP Code:
    //This is the directory where images will be saved
    $targetPic "./inv_Pictures/";
    $targetPic $targetPic basename($_FILES['picture']'name']);
    $picture=($_FILES['picture']['name']);
    move_uploaded_file ($_FILES['picture']['tmp_name'], './inv_Pictures/'.$_POST['mdl_key'].'.jpg' ); 
    This code is run when POST form is submitted. This form DOES work when I have no image for the record with (mdl_key) but when there is already an image and I try to use the form to replace that image, it does not change after submission, it just stays the same picture.

    Any ideas?

    Thanks!
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    move_uploaded_file will replace the file you're uploading unless the web server doesn't have write access to the files. If the image you're overwriting was originally uploaded by PHP, then it should have access.

    Are you sure the file isn't being overwritten? Maybe your browser is caching the image?
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    98
    Rep Power
    2
    Originally Posted by E-Oreo
    If the image you're overwriting was originally uploaded by PHP, then it should have access.
    Originally the listing i was using to test the picture system was indeed uploaded to the server via my OS and not my web server or php. I re-added them via the company application and it does successfully overwrite images now as necessary. Thanks

IMN logo majestic logo threadwatch logo seochat tools logo