?
Solved

file dialog box

Posted on 2006-07-20
3
Medium Priority
?
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
vinodhsomasekharan earned 2000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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