open dialog

cz007j

Freshman
Joined
Jul 28, 2004
Messages
26
Anyone know the correct syntax for an open dialog on a web application. I'm trying to create a button that acts as the open function. But I haven't figured out how to do that in a web form. I know the Windows application has an open dialog built in control, but I don't see one for the web form. And i don't really want to use the html control of file.

Any clues?

Much gratitude in advance
 
Well the html protocol cannot be formatted and thus throw off the design of the webpage. That's why I'm kinda stuck :confused:
 
It can't be formatted because browsers won't let it be formatted. This is for security reasons, so let's be happy it's there. Regardless, you don't have a choice otherwise.
 
Well I'm trying to add an attach function to my smtp email generator. and I wanted to add the open dialog to attach function. Any suggestions?

thank you
 
html control for attaching

Okay I'm using the HTML control "file" to specify the location of my file. But after I attach them and tries to send I get this

Exception Details: System.Web.HttpException: Invalid mail attachment 'C:\Documents and Settings\czhang\Desktop\blah.txt'.

here's my code for attaching:

Dim fileName As String
Dim filePath As String
If file1.PostedFile.FileName.ToString <> "" Then
sAttach= file1.PostedFile.FileName.ToString
end if

file1 being the control

Here's the attach code for sending

Dim myAttachment As MailAttachment = New MailAttachment(sAttach)
MyMail.Attachments.Add(myAttachment)
SmtpMail.Send(MyMail)
 
Do you honestly think the Web server has access to files on your computer? You're giving server-side code a path that resolves to a file on your computer. Think about it. You need to save the bytes sent to the Web server from the client to a local file on the server, and then and only then attach it. Use the HttpPostedFile.InputStream property to read and save the file.
 
yea, i realized it after a bit. Thought maybe it uploads it to some temp folder on the server and go from there. But no. I got it to work now

thanx
 
Back
Top