Rank: Member
Groups: Member
Joined: 4/4/2007(UTC) Posts: 6
|
Does anyone have any advice or suggestions on how to deal with duplicate file names?
Thanks!
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 8/3/2003(UTC) Posts: 998
|
Hello,
What do you mean? What problems? |
|
|
|
|
Rank: Member
Groups: Member
Joined: 12/22/2006(UTC) Posts: 13
|
Hello, I created a namegenerator which creates unique names. You could try to use mine: Code:function generateKey ($length = 8)
{
// Start with a blank key
$keycode = "";
// define possible chars
$possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// set up a counter (to the max length)
$i = 0;
// add random chars to $keycode untill the length is done
while ($i < $length) {
// choose random char from $possible
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
// Is it double (already in the keycode)? Then change to next!
if (!strstr($keycode, $char)) {
$keycode .= $char;
$i++;
}
}
// w00t! A keycode! :)
return $keycode ;
}
That's it. While uploading, you can play with it! Code:FOR EXAMPLE:
$fileName = generateKey(8); // 8 chars. You can change it
Sorry for my English, but the code works ;) Edited by user Tuesday, December 18, 2007 3:37:12 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 9/19/2006(UTC) Posts: 491
Was thanked: 30 time(s) in 30 post(s)
|
Hello, You can add additional POST field with unique filename through AddField method. For example: Code:for (var i = 1; i <= _ImageUploader.getUploadFileCount(); i++)
{
var filename = getUniqueFilename(...);
_ImageUploader.AddField("UniqueFilename_" + i, filename);
}
You can use the same approach and on server side. Edited by user Friday, February 22, 2008 4:11:29 PM(UTC)
| Reason: Not specified |
Best regards, Eugene Kosmin The Aurigma Development Team
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.