Solved

FileStream and file upload

Posted on 2008-10-20
3
3,572 Views
Last Modified: 2009-12-16
I wish to be able to upload files to the server via a file upload control on a ASP.NET Wep application.

Allowed files, any (doc, pdf, etc..)

I wish to use filestream to achieve it by converting the file to binary and saving it into a table/database.

I wish to be able to download the file on a later stage. Be it pdf, exe, doc, txt,.watever

Questions:
1) Is it doable/possible?
2) Are there any easy to understand tutorials I can look at?  As my google did not really return the ones I am looking for or basically too hard for me to understand.
3) Need some understanding on upload and download before proceeding.

Any help will be much appreciated.


0
Comment
Question by:Joshscorp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Assisted Solution

by:philipjonathan
philipjonathan earned 35 total points
ID: 22765054
Have you checked these articles, they have quite a good walkthrough:
http://msdn.microsoft.com/en-us/library/aa479405.aspx
http://www.codeproject.com/KB/aspnet/fileupload.aspx
0
 
LVL 15

Assisted Solution

by:angus_young_acdc
angus_young_acdc earned 35 total points
ID: 22765365
0
 
LVL 2

Accepted Solution

by:
johnhumenik earned 55 total points
ID: 22773421
First off, from experience the performance hit is terrible.  Optimizing the database to handle binary files works, but you will take a hugh hit on performance.  Saving the file to a network share where all the users have access and storing that path (\\server\fileshare) is the best way.  

But if you want to go with uploading data using LINQ, which can be easily translated to SQL Data types also:

            byte[] img = null;
            if (filUploadPicture.HasFile)
            {
                img = new byte[filUploadPicture.PostedFile.ContentLength];
                filUploadPicture.PostedFile.InputStream.Read(img, 0, img.Length);

                using (DBDataContext database = new DBDataContext())
                {
                    Picture newPicture = new Picture();
                    newPicture.Name = "Test Image";
                    newPicture.Description = "Test Description";
                    newPicture.Image = new System.Data.Linq.Binary(img);

                    FileIO thumb = new FileIO();
                    byte[] thumbNail = thumb.ResizePicture(filUploadPicture.PostedFile.FileName, 120, 80);

                    newPicture.Thumbnail = thumbNail;
                    newPicture.IsActive = true;

                    database.Pictures.InsertOnSubmit(newPicture);
                    database.SubmitChanges();
                }
            }
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question