Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am currently in a situation where I've to save Applicants documents in a folder. Suppose if an applicant saves "Resume.txt" then a new entry is made and saved in DB. What if same file is uploaded again(say update "resume" after sometime) ?(currently I'm adding a number after the file and then fetching the latest file, ex : If id_resume.txt already exists then id_resume1.txt will be made and so on. On viewing the document resume1.txt will be opened) How to update the DB accordingly ? So how do other websites manage their document saving viewing and uploading part ?


What I have tried:

There are many codes which I apparently cannot post.
Posted
Updated 27-Feb-18 4:37am
Comments
F-ES Sitecore 27-Feb-18 10:49am    
The easiest thing is to store the files in the database rather than keeping them on disc. If you do keep them on disc then you're also going to have to come up with a folder strategy. Monster probably have over 1,000,000 resumes, do you think they have a folder somewhere with 1,000,000+ files in it? Instead you'll need some way of storing the files in a tree structure to keep the number of files per folder around a sensible limit.

I wouldn't worry about maintaining an archive of older files unless that's a specific requirement. If it is, you can establish a max number of old files to maintain to keep disk usage on the file system server to a dull roar. Files can quickly overwhelm available disk space on a busy site. You may also want to restrict uploads to specific file types (PDF, DOC, XLSX, ZIP, etc) and a maximum size.
 
Share this answer
 
Probably the same many versioning systems work.
The most basic way to do it is:

Don't store the file under it's name - it's very likely that thousands of people will submit a file called "resume.txt" or "resume.docx" - and you want to keep them separate.
Instead, use a GUID as the file name, and add a table which links the UserID to teh files he has submitted:
ID         GUID or IDENTITY
UserID     Foreign key to your Users table
FileRef    GUID (the actual file storage name)
FileName   The names as supplied by the user
Submitted  DATETIME or DATETIME2 when the file was submitted
Each time he submits a file, you generate a new row.
You can fetch each users latest file by looking at the Submitted date, and still access earlier versions.

There are more complex systems (where the newer files are stored as differences from previous versions) but they can get very complicated if you aren't careful. Storage is cheap enough, and you can always archive older versions if necessary.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900