Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto: uploading files - what to do if the filenames are identical? 2

Status
Not open for further replies.

Deadline

Programmer
Feb 28, 2001
367
US
Hi

I am using Persits' ASPUpload component. While it works fine, I am wondering what to do if two or more files being uploaded share the same file name.

When I saw their documentation, it reads something like this...

Forcing Unique File Names

By default, AspUpload will overwrite existing files in the upload directory. If this is undesirable, the component can be configured to generate unique names for the files being uploaded to prevent overwriting existing files in the upload directory. This is done by setting UploadManager's OverwriteFiles property to False before calling Save:
Upload.OverwriteFiles = False

This property is True by default.

To prevent name collisions, AspUpload will append the original file name with an integer number in parentheses. For example, if the file MyFile.txt already exists in the upload directory, and another file with the same name is being uploaded, AspUpload will save the new file under the name MyFile(1).txt. If we upload more copies of MyFile.txt, they will be saved under the names MyFile(2).txt, MyFile(3).txt, etc.


But when I store the fileNames in the database, I am storing something like "C:\Upload\MyFile.Jpg".
This thanks to the component's Path property.

But when saving, if the component changes the filename, i.e, adds a number in paranthesis, how'd I update the database to reflect the value ? I hope you got my doubt..

Can you help me out of this??
Thank you...
RR

 
Using an online job application form allowing applicant's to upload their resumes:

When the applicant's record is added to the database, a unique applicant id is generated. Then that id is used as a prefix for the filename uploaded, assuming many people will call their resume 'resume.doc', renaming the file to '112_resume.doc'

Using a unique prefix will eliminate the possibility of duplicate filenames.
 
Try to save the name in database after u save the file. Maybe after that u get the right name of your file... ________
George, M
 
Wow.. So you mean, I need to rename and push the filename into the database, am I right ?

Thank you very much. I already given you a star.. :) Thank you...
RR

 
Wow.. So you mean, I need to rename and push the filename into the database, am I right ? Yes, and thank you!
 
That gives way for another doubt... I store the filename as "MyFile.Txt"

If I add an ID value at the end of each file name, then how to extract the file, as that is no longer a text file but a file with an extention say.. MyFile.txt124423 ??




Thank you...
RR

 
Ohh I'm sorry..The word "Prefix" escaped my attention..

Apologies.
Thank you...
RR

 
don't add it to the end, add it to the beginning (prefix), ie. 23_myfile.txt, 45_myfile.txt, 564_myfile.txt, etc.

(-:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top