Solved

file dialog box

Posted on 2006-07-20
3
227 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now