stelogic
asked on
Image Replacement
Thanks for taking the time to read this ..
I have an image upload script that works perfectly .. now i want , that if an image is uploaded with the same name as an image that already exists it replaces the image with the new one..
i tried removing the section below but that just produced new errors
All help welcome even if it is another script that does what i want or a link to one.
************************** ********** ********** ***
Section i tried removing
if(file_exists("$ADMIN[dir ectory]/$p icture1") OR $ok == 2) {
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$pictur e1");
$error .="File $num has been uploaded<BR>";
}
}
}
************************** ********** ********** ***
FULL SCRIPT
<?php
exit();
}
}
$num = 0;
while($num < $ADMIN[UploadNum]) {
$num++;
$picture = "fileup$num"."_name";
$picture1 = $$picture;
$picture2 = "fileup$num";
$picture3 = $$picture2;
if($picture3 != "none") {
$filesizebtyes = filesize($picture3);
$ok = 1;
if($filesizebtyes < 10) {
$error .= "Error uploading (file size lower than 10 bytes) for file $num<BR>";
$ok = 2;
}
if(file_exists("$ADMIN[dir ectory]/$p icture1") OR $ok == 2) {
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$pictur e1");
$error .="File $num has been uploaded<BR>";
}
}
}
if(!$error) {
$error .= "No files have been selected for upload";
}
?>
Cheers
Steve
I have an image upload script that works perfectly .. now i want , that if an image is uploaded with the same name as an image that already exists it replaces the image with the new one..
i tried removing the section below but that just produced new errors
All help welcome even if it is another script that does what i want or a link to one.
**************************
Section i tried removing
if(file_exists("$ADMIN[dir
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$pictur
$error .="File $num has been uploaded<BR>";
}
}
}
**************************
FULL SCRIPT
<?php
exit();
}
}
$num = 0;
while($num < $ADMIN[UploadNum]) {
$num++;
$picture = "fileup$num"."_name";
$picture1 = $$picture;
$picture2 = "fileup$num";
$picture3 = $$picture2;
if($picture3 != "none") {
$filesizebtyes = filesize($picture3);
$ok = 1;
if($filesizebtyes < 10) {
$error .= "Error uploading (file size lower than 10 bytes) for file $num<BR>";
$ok = 2;
}
if(file_exists("$ADMIN[dir
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$pictur
$error .="File $num has been uploaded<BR>";
}
}
}
if(!$error) {
$error .= "No files have been selected for upload";
}
?>
Cheers
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Anything else needed on this question?
ASKER
Thanks
Steve