Solved

file dialog box

Posted on 2006-07-20
3
230 Views
Last Modified: 2012-05-05
The following asp code opens up an "open file dialog" box:

<body>
          <form id="Form1" method="post" runat="server">
             <input type="file" runat="server" id="fDocument"/>
               <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
               <asp:CheckBox id="CheckBox1" runat="server" Text="Save"></asp:CheckBox>
          </form>
     </body>

Is there anything similar to this that opens up a "save as" file dilog box?  All I need it to do is allow the user to select a place on their file system where they want to save a file.  I will take the string value of the file path that it returns and will then be able to save the file in the appropriate location.

Thanks,

Ryan
0
Comment
Question by:dchau12
3 Comments
 
LVL 5

Accepted Solution

by:
vinodhsomasekharan earned 500 total points
ID: 17151699
Hai,

I think u can form a hyperlink for each file and on its click event in server side u can just call the following code..

filename -- > the file which user has choosen....

            dim fileStream  as System.IO.FileStream
            fileStream = System.IO.File.Open(filename, IO.FileMode.Open, IO.FileAccess.Read,            IO.FileShare.Read)
            ReDim bytDocument(fileStream.Length)
            fileStream.Read(bytDocument, 0, fileStream.Length)

            Response.Clear()
            Response.AddHeader("content-disposition", "attachment; filename=""" & filename & """")
            Response.AddHeader("Content-Length", bytDocument.Length.ToString())
            Response.ContentType = "application/octet-stream"

            Response.BinaryWrite(bytDocument)
            Response.Flush()
            Response.Close()
            Response.End()

The above code will pop up a open/save/cancel dialog box.. which user can choose to save to his own machine..

Is this r u looking for.. ??

Regards
Vinodh
0
 
LVL 2

Expert Comment

by:SKumar_1981
ID: 17152759
Try this,
dim fileStream  as System.IO.FileStream
            fileStream = System.IO.File.Open(filename, IO.FileMode.Open, IO.FileAccess.Read,            IO.FileShare.Read)
            ReDim bytDocument(fileStream.Length)
            fileStream.Read(bytDocument, 0, fileStream.Length)

            Response.Clear()
            Response.AddHeader("content-disposition", "attachment; filename=""" & filename & """")
            Response.AddHeader("Content-Length", bytDocument.Length.ToString())
            Response.ContentType = "application/octet-stream"

            Response.BinaryWrite(bytDocument)
            Response.Flush()
            Response.Close()
            Response.End()
Regards,
skumar
0
 

Author Comment

by:dchau12
ID: 17153751
Ahhh!!!!!

This was a lot like the original code I had that did not work!  The difference was that I did not include the code to flush the buffer and close the connection.  Without these three lines of code, it was adding jibberish text to the end of my binary files.  This jibberish corrupted my pdf files.

Thank You!

Ryan
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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