Link to home
Start Free TrialLog in
Avatar of stelogic
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[directory]/$picture1") OR $ok == 2) {
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$picture1");
$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[directory]/$picture1") OR $ok == 2) {
$error .="File name already exists for file $num<BR>";
} else {
copy ($picture3, "$ADMIN[directory]/$picture1");
$error .="File $num has been uploaded<BR>";
}
}
}

if(!$error) {
$error .= "No files have been selected for upload";
}


?>

Cheers

Steve
ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stelogic
stelogic

ASKER

Genius Mate..Pure Genius

Thanks

Steve


Anything else needed on this question?