Click here to Skip to main content
15,899,126 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hye,

I need to open a document of type (pdf, doc, docx, xlsx etc) and download and save it.

The whole scenario is:

I am working on a mobile website where user can log in and add some of there information and then some documents are created according to these information given of the above types.
Now the Title of those documents are listed in "ul, li"
Also these Documents are not saved in any folder but else its contents are to be saved in Database as byte array along with its extension. At the time I click the link, it should fetch all the information and a popup should appear asking whether to save or open the file. If I click save, it should download the file and save it in mobile's SD card.

Now, Please let me know how can I do this :

C#
this.Response.Clear();
               this.Response.ContentType = MimeType;
               this.Response.AppendHeader("Content-Disposition", "attachment;filename=demoFile" + DocumentExtension);
               Response.OutputStream.Write(DocumentContent, 0, DocumentLength);
               Response.Flush();
               Response.Close();



through javascript.

Is there any way.
and if not, how can I let a file either to open or save and if clicked "save" it downloads and save.

I don't have any path for that file, as the file is not saved somewhere, all the data is taken from database.

i have to render the byte array, how can I do this.

Thanks in advance.

[Also please prefer the code is to be in javascript]
Posted
Updated 15-Nov-11 0:22am
v5
Comments
Mehdi Gholam 15-Nov-11 6:04am    
The browser normally does this for you.

You can open word/excel through javascript. You have to use ActiveX object. here is link. Open_Word_Excel_using_JavaScript[^]
 
Share this answer
 
Comments
DeepsMann 15-Nov-11 5:59am    
yes, but I think it will not work on mobile browsers.
koolprasad2003 15-Nov-11 6:24am    
have you tried ?
Hye,

I have done it using web service.
At the time I click a link to download a file,
a web method is called, which retrieve the byte array of that document from
Database, prepare the document and write it on the response.
The browser itself starts downloading that file, as it doesn't support the format to open.

Cheers.. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900