?
Solved

file dialog box

Posted on 2006-07-20
3
Medium Priority
?
235 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 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