This is a migrated thread and some comments may be shown as answers.
Unique file names: prevent overwriting files in TargetFolder
2 Answers 8 Views
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 30 Jan 2015, 06:59 PM
When a file gets uploaded to the temporary folder its name is changed to ensure that it is unique. However the file gets copied to the TargetFolder with its original name. If two people upload files with the same name at the same time then the latter will overwrite the former. How can I ensure that each file in the TargetFolder will be unique so as to prevent collisions?

2 Answers, 1 is accepted

Sort by
0
SANJAY
Top achievements
Rank 1
answered on 31 Jan 2015, 08:55 AM
Hi Mike

I would like to bring forward two options

1) Can rename the file by appending the count of file to the name of the file. Eg if the original name is sample.txt then for the first file rename to 1sample.txt . So every time a file is uploaded the count would give a unique name
2) rename the file with new guid string. Problems with is are
     a) Long names
     b) The loss of name may not be able to identify the content of files

0
Mike
Top achievements
Rank 1
answered on 02 Feb 2015, 06:59 PM
Thanks. I hadn't been able to figure out how to rename the file but I finally found this post.
Asked by
Mike
Top achievements
Rank 1
Answers by
SANJAY
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or