.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

File Upload to database (and download)

Posted By:      Posted Date: September 19, 2010    Points: 0   Category :ASP.Net


How can I upload a file to a database (with as little code as possible!) along with a desciption of a file and then search through the descriptions to retrieve the appropriate files. Then how can I click on one and download it.

I am not a very advanced programmer and would like full step by step code if possible not just a link to a website.

Thank you very much


View Complete Post

More Related Resource Links

Insert Excel Data via File Upload into sql server database???

Hi all, I have requirement that User can Upload the Excel Sheet Data to sql server Database at once. How i do that Any Article or hint is apperciated.   Regards 

Upload image to database - couldn't find file path

I'm trying to display images in a GridView (yes, still this...). [edit] Before I can come to that I have to upload some images to the database.I've followed this tutorial for the "upload image to database" code (this worked fine for uploading images, but I don't know if the images were converted to byte):http://aspsnippets.com/Articles/Save-Files-to-SQL-Server-Database-using-FileUpload-Control.aspxand I've followed this tutorial for the "display images in gridview" code (and "retrieve file" from the tutorial below).http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspxIt doesn't quite work, the GridView shows but without imagesNow I'm trying to change the "save file" code according to this tutorial:http://aspsnippets.com/Articles/Save-and-Retrieve-Files-from-SQL-Server-Database-using-ASP.Net.aspxbut I don't understand everything in it. When I try to upload an image I get an error on this line:FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); //couldn't find file (path to image I tried to upload) What should I do about it?

Upload file to server or database

hi,I'd like to know how to allow user to upload file to the server in mvc 2 application. I haven't seen a very clear tutorial for this, at least not on this website. There is a movie database tutorial but that is simply a list of movies not actual files. What is the simplest method for uploading files, be they images or movies? Thank you for your time.

Can i upload file to database table using AsyncFileUpload ?



can i upload my pdf or word file to oracle/SqlServer database table ?

How ? 

how to set a client folder to get upload and download the file.


i create a web site for uploading and download but i require that a folder create in client side if client download the file these file automatically save 

File/document upload.download in a web farm


I have an asp.net application running on a web farm that allows users to upload files and download them later via link to that file.  Currently, I use Windows DFS to replicate the local IIS directory where the files are stored across the web farm servers.  However, as this solution does not scale out, I want to implement a more scalable solution by partitioning the documents.  Specifically, say I set up multiple file storage servers (Fs1, Fs2, Fs3, etc.) on the network.  Further, let's say I change my upload page to save the uploaded file to one of the file storage servers on the local LAN (based on some logic).  I assume so far I am safe with ASP.NET doing this much assuming I have the correct permission for the ASP.NET process ID.  The question I have is with regards to download links.  When a user gets served a download link to their document (e.g. http://www.testco.com/data/doc1.txt) is there a way for me to "intercept" that HTTP request and underneath the covers server the doc1.txt from the file storage server (e.g. Fs2) it resides on?  Any sample code would be appreciated.  Thanks. 

web service file download and upload



I am trying to create a web service that can check a location for file and if available get the contents.

Also this web service has to upload the file using ftp after making changes locally.

Any pointers in this direction.



How to insert Database and Upload file


I have TBL_PRODUCT table : ProductID, ProductName, CategoryID, Image.

I can insert data to table :

public ActionResult Create(tbl_products products)

       return Redirect("Index");

I can upload image file too

public ActionResult UpHinh(HttpPostedFileBase fileImg)
       var fileName = Path.GetFileName(fileImg.FileName);
       fileImg.SaveAs(Server.MapPath("/Content/Images/" + fileName));

       return Redirect("Index");

But I want two function become one. When I press <Submit>, it's insert data and upload image file.

Help me. Thanks

File Upload to Database


Hi All

I'm using a DetailsView control and have a FileUpload control in a TemplateField for uploading images to a database.

However, I'm not sure how to take the image name e.g. Button.png as a value and enter it into the database.

Thanks for your help.

Uploading .pdf files with FIle Upload control and then saving to database


Hi everyone!

I'd like to allow users to upload a .pdf file via the file upload control (if that's the best method), save the file to the db and then retrieve it so they can click on a link and open the .pdf they've uploaded.

I've been looking for a tutorial on how to do this but keep running into methods of saving the file directly on the server in a directory, not in SQL server  (using Linq and VB by the way)

Can someone please point me in the right direction on how to do this?   Thanks!

Download a File from a Database Using LINQ to SQL


I have used AsyncFileUpload AJAX control to upload a file to a column in a SQL Server database using LINQ to SQL.  Below is the code.  How do I retrieve the document and allow the user to save to local drive using a Save As Dialog box using LINQ to SQL?  This is ASP.NET web application.  The DocumentFileContent database column is a Image SQL Server data type.  Thanks

var VRRRMDataDataContext = new VRRRMDataDataContext();

VRRRMWeb.AllUsers.Document custDocument = new VRRRMWeb.AllUsers.Document
   DocumentFileName = AsyncFileUpload1.FileName,
                        DocumentDescription = txtDocmentDescription.Text,
                        DocumentFileContent = AsyncFileUpload1.FileBytes,

INSERT NULL value in SQL database when there is no file to upload



I've been working on a code that allows users to upload images (jpgs) as an optional field. Alhough the uploading works, I'm struggling when the user doesn't have an image to upload. I can't seem to find the way to NOT insert binary data into my database, I just want an NULL value when there is no image.
I get this error message: ...expects parameter @Image, which was not supplied.


Here is the code: 

Sub InsertItem()

Dim imageData As Byte() = Nothing
Dim MIMEType As String = ""


How to upload a file to web server in asp.net and store file path into database table?

This article describe how to upload a file into web server folder using asp.net file upload control and store the file information into sql server database.

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

Multi File Upload Using JQuery!

Everyone knows about the file upload in .NET. But the multi file upload is some what difficult in .NET. For that purpose we can have some AJAX or JQuery!. Jquery is the latest advanced version. It will give some animated upload. You can try it for your own!!!!

ASP.Net Upload Image to MS Access Database

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table "tblImg" with the following fields:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend