|
-
Jun 19th, 2015, 02:32 PM
#1
Thread Starter
Frenzied Member
Saving files for asp.net web application
I'm creating a web application where the users can upload and download files. In the past, I've usually done so by saving the files as binary in a sql database. I did this because, this way, I know which files belong to which users (based on an ID). How would I do this if I plan on saving the files on the HDD? I figure I would create a unique folder per user (and I would save their files there), but I'm wondering what the standard or better way of approaching this.
-
Jun 19th, 2015, 04:47 PM
#2
Re: Saving files for asp.net web application
The simplest approach is to create a user table and another table for file location per user.
I would never save a file on the database, it takes ages to download vs a folder files and is not a good way to go, unless on special cases (that in your case, this does not apply).
So when a user first register (or you register him trough a console), write his/her's id on the user table and create a folder with , possibly, the username as the folder name. Every file uploaded by the user would have the path written to the file location table.
Just a very simple approach without security considerations and multiple folder path selections to get you started.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jun 19th, 2015, 05:15 PM
#3
Thread Starter
Frenzied Member
Re: Saving files for asp.net web application
Thanks. And what should happen if the user ends up uploading a file of the same name? Should my web application just rename it when it saves it in the unique user's folder?
-
Jun 21st, 2015, 12:32 PM
#4
Re: Saving files for asp.net web application
That is up to you i guess but you should probably warn that the file exist and either keep o copy and overwrite or just overwrite .
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|