Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Bind File to Record in the Database

Bind File to Record in the Database

Scheduled Pinned Locked Moved ASP.NET
databasesysadminhelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muhammad Gouda
    wrote on last edited by
    #1

    In my page, the visitor will fill in a form and can upload a file. I do not need to save the file itself to the database, rather I save the file to a folder on the server with a reference in my table. The Problem is: if more than one file with the same name and extension were uploaded, each one will overwrite the older one I have 2 solutions of my own: 1- I can create a sub-folder with a name same as the primary key of the record this file belongs to. and upload the file to that sub-folder 2- I can append the primary key as a prefex to the file name But, I think this problem has more smart solution that I faild to find by google or even in codeproject articles

    Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

    O F 2 Replies Last reply
    0
    • M Muhammad Gouda

      In my page, the visitor will fill in a form and can upload a file. I do not need to save the file itself to the database, rather I save the file to a folder on the server with a reference in my table. The Problem is: if more than one file with the same name and extension were uploaded, each one will overwrite the older one I have 2 solutions of my own: 1- I can create a sub-folder with a name same as the primary key of the record this file belongs to. and upload the file to that sub-folder 2- I can append the primary key as a prefex to the file name But, I think this problem has more smart solution that I faild to find by google or even in codeproject articles

      Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

      O Offline
      O Offline
      outside cosmic
      wrote on last edited by
      #2

      SQL Server 2008 will have support for what you are trying to do - http://www.infoq.com/news/2007/12/SQL-Filestream[^] so until this is out your on the right tracks with your own solutions.

      1 Reply Last reply
      0
      • M Muhammad Gouda

        In my page, the visitor will fill in a form and can upload a file. I do not need to save the file itself to the database, rather I save the file to a folder on the server with a reference in my table. The Problem is: if more than one file with the same name and extension were uploaded, each one will overwrite the older one I have 2 solutions of my own: 1- I can create a sub-folder with a name same as the primary key of the record this file belongs to. and upload the file to that sub-folder 2- I can append the primary key as a prefex to the file name But, I think this problem has more smart solution that I faild to find by google or even in codeproject articles

        Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

        F Offline
        F Offline
        farazsk11
        wrote on last edited by
        #3

        What solutions you have suggested are good you can also do one more thing is to rename the file either with the primary key or some GUID name and keep the actual file name and path of the file in the database so that when you display the file you can show it with actual name and on the backend its with some different unique name.

        Faraz Shah Khan MCP, MCAD.Net Blog

        M 1 Reply Last reply
        0
        • F farazsk11

          What solutions you have suggested are good you can also do one more thing is to rename the file either with the primary key or some GUID name and keep the actual file name and path of the file in the database so that when you display the file you can show it with actual name and on the backend its with some different unique name.

          Faraz Shah Khan MCP, MCAD.Net Blog

          M Offline
          M Offline
          Muhammad Gouda
          wrote on last edited by
          #4

          Thanks But I gussed there is more standarad direct solution

          Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

          F 1 Reply Last reply
          0
          • M Muhammad Gouda

            Thanks But I gussed there is more standarad direct solution

            Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

            F Offline
            F Offline
            farazsk11
            wrote on last edited by
            #5

            To be more honest I have not seen any better solution so far as the above 3 solutions. any way there still can be a better way but I couldn't find any thing wrong in this one.

            Faraz Shah Khan MCP, MCAD.Net Blog

            M 1 Reply Last reply
            0
            • F farazsk11

              To be more honest I have not seen any better solution so far as the above 3 solutions. any way there still can be a better way but I couldn't find any thing wrong in this one.

              Faraz Shah Khan MCP, MCAD.Net Blog

              M Offline
              M Offline
              Muhammad Gouda
              wrote on last edited by
              #6

              farazsk11 wrote:

              but I couldn't find any thing wrong in this one.

              One of the lacks of the above 3 solutions is that them all depend on the primarykey. And I generate the primarykey on the submit event (for some reason) So, how to use it in the upload event before it is generated :confused:

              Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

              F 1 Reply Last reply
              0
              • M Muhammad Gouda

                farazsk11 wrote:

                but I couldn't find any thing wrong in this one.

                One of the lacks of the above 3 solutions is that them all depend on the primarykey. And I generate the primarykey on the submit event (for some reason) So, how to use it in the upload event before it is generated :confused:

                Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

                F Offline
                F Offline
                farazsk11
                wrote on last edited by
                #7

                Well as a matter of fact I usually use GUID to rename files and as the GUID is generated in the code I pass it in the database. I usually store the GUID name and the actual name so that when the user request I can display it as actual name and on the backend i keep it with GUID.

                Faraz Shah Khan MCP, MCAD.Net Blog

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups