简体   繁体   中英

How do I Open a file directly(from the binary data saved in db), when I will click a link?

I am working on a file uploading functionality using ASP.NET, C# and telerik. I am using telerik:RadAsyncUpload control. I already convert the file to byte array and save in the SQLServer Database. On update page, I need to open file directly(from the binary data saved in db), when I will click a link. I need to Open that file in separate browser tab/window. I do not want to save file Physically on any local drive while retrieving it.

Please help me out.

What I have tried? For time been, I am saving that binary data in a blank file located at some local drive and then attaching it to that link. but I do not want to save file Physically on any local drive while retrieving it. I want .....when user will click link binary data will directly flush on separate browser tab and he can view the file.

Create a handler (arbitrary one or an aspx page, whatever you find easier) that will read the database (eg, based on a querystring argument) and return the appropriate response (via the Response object, eg, Response.BinaryWrite()).

Note that you should set the appropriate headers and that depending on the type of file you return the browser may prompt the user to open/save it instead of opening it inline. You have some control over that via the content-disposition HTTP header, but it is ultimately up to the browser.

Also, you may want to use a RadWindow to open that handler to keep browser popups to a minimum to reduce the risk of them getting blocked by the browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM