I am creating a catalog in php that lets someone add a picture attached to a record, and then edit the same record. The problem I am having is that when a record containing a picture is being edited, unless the same picture is browsed and selected, the code returns a null value which overwrites the previous picture. Obviously this is not good. I thought that I could parse a variable "change_picture" (with yes no option - if no is selected it would bypass the upload feature all together) This seems a messy and uneccessary solution. The upload picture code I am using follows - I think there must be something I can do here which could check whether the $uploadedfile_name variable is already filled, and then bypass the upload function automatically (I am parsing the $uploadedfile_name variable via a hidden field on the previous page) Here is the code:
if($uploadedfile<>"none") {
if(!copy($uploadedfile,"files/$uploadedfile_name")) {
print("Your File failed to upload.<br>");
print("The file may have been too large.");
print("Please use your back button and try again.");
}
else {
print("Your file has been uploaded.");
}
}
I am a cut a paste programmer and would really appreciate any help.
Regards -
Gordon Candelin