Bind File to Record in the Database
-
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++;
-
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++;
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.
-
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++;
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.
-
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.
Thanks But I gussed there is more standarad direct solution
Mohammed Gouda foreach(Minute m in MyLife) myExperience++;
-
Thanks But I gussed there is more standarad direct solution
Mohammed Gouda foreach(Minute m in MyLife) myExperience++;
-
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++;
-
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++;
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.