Jump to content

Uploaded file same name collision solution


lindylex

Recommended Posts

I am working on creating a php photo gallery.  The problem I have is when a user uploads a file with the same name I would like to write the file and not overwrite the previous.  What would be an elegant way to solving this problem?

 

I assume some type of unique naming for the duplicated file.  Can someone give a nice suggestion?

 

Thanks,

Lex

Link to comment
Share on other sites

rhodesa,

 

When some remove the image from the table how does the datase handle the next file?  I assume the id is a sequence of numbers like

 

id 0 = 1st image

id 1 = 2 nd image

 

when you delete id 0, 1st image, then what will be the id of the next photo uploaded?

 

Thanks, for the quick reply?

 

Lex

Link to comment
Share on other sites

rhodesa,

 

When some remove the image from the table how does the datase handle the next file?  I assume the id is a sequence of numbers like

 

id 0 = 1st image

id 1 = 2 nd image

 

when you delete id 0, 1st image, then what will be the id of the next photo uploaded?

 

Thanks, for the quick reply?

 

Lex

Hello,

The next photo can be id2 ;)

 

It doesn't matter how you number them. You can go up to 1000000 (a million) if need be. But it doesn't matter. So if id0 is missing, then the link would just not work. It's fine.

 

Ken

Link to comment
Share on other sites

Any rows that are deleted will delete the id number and NEVER use it again

 

next insert will always be the next number after the last insert

 

so if you have

 

id

146

147

148

 

you delete 147, the next insert will still be 149. Even if 148 is deleted next the insert will still be 149. The counter is kept track of internally.

 

ray

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.