Results 1 to 4 of 4

Thread: Saving files for asp.net web application

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    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.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    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?

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    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
  •  



Click Here to Expand Forum to Full Width