Log in

View Full Version : totally baffled



Randomer
08-01-2008, 09:45 PM
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?

QuickScriptz
08-01-2008, 10:01 PM
Well you could start by posting your original script... basically what you would need to do is:

Pseudo 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).ra nd(9);
$newfile = $filename.$ext;
if(file_exists($newfile)){
// Try again for a new filename
}else{
// Upload file with the new filename
}
?>


Note that "Pseudo Code" won't actually do what you're in need of but just provides an example of the logic you should use :)

Randomer
08-01-2008, 10:08 PM
nevermind..

Sorted it..

Want to hide these adverts? Register an account for free!