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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.