Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

Posted

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)

  • *Gurus*
Posted
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.
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...