cz007j Posted August 24, 2004 Posted August 24, 2004 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 Quote
Administrators PlausiblyDamp Posted August 24, 2004 Administrators Posted August 24, 2004 If you wish the user to be able to browse to a file for upload then you will need to use the HTML control - is there a reason why you do not want to do this? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cz007j Posted August 25, 2004 Author Posted August 25, 2004 Well the html protocol cannot be formatted and thus throw off the design of the webpage. That's why I'm kinda stuck :confused: Quote
*Gurus* Derek Stone Posted August 25, 2004 *Gurus* Posted August 25, 2004 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. Quote Posting Guidelines
cz007j Posted August 25, 2004 Author Posted August 25, 2004 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 Quote
Administrators PlausiblyDamp Posted August 25, 2004 Administrators Posted August 25, 2004 If you want this to be usable from any browser then that is your only option Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cz007j Posted August 25, 2004 Author Posted August 25, 2004 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) Quote
*Gurus* Derek Stone Posted August 26, 2004 *Gurus* Posted August 26, 2004 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. Quote Posting Guidelines
cz007j Posted August 26, 2004 Author Posted August 26, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.