I am using this upload file script:
But everytime someone uploads the same image name, the image is over-written.Code:<? // Where the file is going to be placed $target_path = "images/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['Image1']['name']); $_FILES['Image1']['tmp_name']; $target_path = "images/"; $target_path = $target_path . basename( $_FILES['Image1']['name']); if(move_uploaded_file($_FILES['Image1']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['Image1']['name'])." has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?>
So this is a little problem because users might upload same image names
How can i prevent the script from overwritting old images



Reply With Quote

Bookmarks