Solved

file dialog box

Posted on 2006-07-20
3
232 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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