yer i have an image upload script but the thing is when uses upload an image if it has the same filename as one already uploaded it doesnt work..
so what can i add to my upload script so it changes the filename?

yer i have an image upload script but the thing is when uses upload an image if it has the same filename as one already uploaded it doesnt work..
so what can i add to my upload script so it changes the filename?
Well you could start by posting your original script... basically what you would need to do is:
Pseudo Code:
Note that "Pseudo Code" won't actually do what you're in need of but just provides an example of the logic you should usePHP Code:<?php
// Do Uploading bit here...
$ext = Uploaded Files Extension (.gif, .jpg, etc.);
$filename = rand(9).rand(9).rand(9).rand(9).rand(9).rand(9).rand(9);
$newfile = $filename.$ext;
if(file_exists($newfile)){
// Try again for a new filename
}else{
// Upload file with the new filename
}
?>![]()
Last edited by QuickScriptz; 08-01-2008 at 10:03 PM.
nevermind..
Sorted it..
Last edited by Randomer; 08-01-2008 at 10:09 PM.
Want to hide these adverts? Register an account for free!