December 9th, 2012, 07:08 PM
Image replacement, with move_uploaded_file
I'm having trouble with some code.
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.
//This is the directory where images will be saved
$targetPic = "./inv_Pictures/";
$targetPic = $targetPic . basename($_FILES['picture']'name']);
move_uploaded_file ($_FILES['picture']['tmp_name'], './inv_Pictures/'.$_POST['mdl_key'].'.jpg' );
December 9th, 2012, 11:41 PM
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?
December 11th, 2012, 03:51 PM
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
Originally Posted by E-Oreo