Need help overwriting file from submission page

I am trying to add a way for a user to change a status image through the use of PHP. I am not sure where I need to go next with my code. I want the user to be able to make a selection from one page that copies/overwrites another image so that it will automatically appear when a visitor visits the main page. All I need to do is copy one image file renaming and overwriting another. For example: open.jpg or closed.jpg xyz.jpg I am not sure where to define the image to copy/rename/overwrite. I am seeing a lot of helps for FTP issues, but not for doing this. The 3 images are all in the same images folder. Can anyone help me? Is this even possible in PHP?

<?php // define variables and set to empty values $WinterStatusErr = ""; $WinterStatus = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["WinterStatus"])) {$WinterStatusErr = "Status is required";} else {$WinterStatus = test_input($_POST["WinterStatus"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?>

* required selection

"> Set Winter Weather Status:
value="Open">Open value="Closed">Closed * <?php echo $WinterStatusErr;?>

unless you are having the user UPLOAD a new image to be displayed, then you don’t want to copy and over-write images at all. you want to have both images available and just have the page display whichever one fits.

unfortunately that will require some changes to the rest of your code. i’m assuming you don’t want to do that so check out: http://php.net/copy

Sponsor our Newsletter | Privacy Policy | Terms of Service