How to download files??
-
Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma
-
Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma
set navigateurl to physical address of that file
-
Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma
SqlCommand command = new SqlCommand("proc_GetImages", connection); command.CommandType = CommandType.StoredProcedure; SqlDataReader rd = command.ExecuteReader(); byte[] image = null; while (rd.Read()) { image = (byte[])rd[0]; str = rd[1].ToString(); //content type of file } rd.Close(); Response.ContentType=str ; Response.Buffer=true; Response.AddHeader("Content-Disposition", "attachment; filename=" + name + ";"); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.End();
use this code to download file stored in database -
set navigateurl to physical address of that file
How will we set the navigate URL? Can you pls give me an example. I tried by setting the href of anchor tag. But for excels files it is not working.
-
SqlCommand command = new SqlCommand("proc_GetImages", connection); command.CommandType = CommandType.StoredProcedure; SqlDataReader rd = command.ExecuteReader(); byte[] image = null; while (rd.Read()) { image = (byte[])rd[0]; str = rd[1].ToString(); //content type of file } rd.Close(); Response.ContentType=str ; Response.Buffer=true; Response.AddHeader("Content-Disposition", "attachment; filename=" + name + ";"); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.End();
use this code to download file stored in databaseThank you but my file is stored on the hard disk. I am storing files on the server. Now I want to download them from the application.
-
Thank you but my file is stored on the hard disk. I am storing files on the server. Now I want to download them from the application.
Perhaps this will help: http://www.codeproject.com/KB/tips/HowToUseGoogle.aspx?msg=2458041#xx2458041xx[^] The person who answered you here has given you all the important information ( that is, how to use the response object to write a file back out for download ). In fact, what you want is simpler, you just need to read the file bytes from the file system.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )