wsyeager Posted February 7, 2005 Posted February 7, 2005 I'm using the HTML "FileField" control to browse to a file. Once it's selected, I then use a linkbutton to try and upload the file to the app. This works fine if the webserver is local to my machine. However, once the app is on another webserver instead of my local machine, it can't find the file. I tried putting a file on our development web server to access. When I browse to the exact same filename on my local machine, it finds the file only because it exists on the webserver. This means that the "Browse" button of the control is looking on the webserver, not the users' local machine. Therefore, how do I update the pathname of the file to get the correct file from the users' machine and not the webserver? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Administrators PlausiblyDamp Posted February 7, 2005 Administrators Posted February 7, 2005 http://www.xtremedotnettalk.com/showthread.php?t=91067 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
wsyeager Posted February 7, 2005 Author Posted February 7, 2005 I've tried implementing the code you supplied, but this just reads data inside the actual file being uploaded. I just want to get the pathname of the file? I'm using the following code: <code> Dim filecontrol As HtmlControls.HtmlInputFile filecontrol = DirectCast(Me.FindControl("ffRequestDoc"), HtmlControls.HtmlInputFile) Dim strReqFrmDoc As String = filecontrol.PostedFile.FileName </code> However, like I said before, it's giving me problems accessing the correct path when I access my app from a web server other than my local machine. How can I resolve this? http://www.xtremedotnettalk.com/showthread.php?t=91067 Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Administrators PlausiblyDamp Posted February 7, 2005 Administrators Posted February 7, 2005 Like I said in the other thread, a web server cannot access files on a client's machine. The .FileName property will give you the path of the file on the client - this can be useful if you need to store the posted file somewhere on the web server and wish to give it a name, but it will not allow the server to access the file on the client. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
wsyeager Posted February 7, 2005 Author Posted February 7, 2005 I got it now... After browsing to the file with the input control, I then use a linkbutton to actually add the document to a collection and eventually add it to SQL Server as follows: <code> Dim filecontrol As HtmlControls.HtmlInputFile filecontrol = DirectCast(Me.FindControl("ffRequestDoc"), HtmlControls.HtmlInputFile) Dim txtDetailedDescr As TextBox = DirectCast(Me.FindControl("txtDetailedDescr"), TextBox) Dim sr As New StreamReader(filecontrol.PostedFile.InputStream) . . . 'Add attachments to collection Dim drAttachments As dstRequests.AttachmentsRow = DstRequests1.Attachments.NewAttachmentsRow drAttachments.AttachmentName = strAttachmentName drAttachments.AttachmentDescription = txtDetailedDescr.Text.Trim drAttachments.FileType = filecontrol.PostedFile.ContentType drAttachments.PathName = filecontrol.PostedFile.FileName drAttachments.FileLength = filecontrol.PostedFile.ContentLength drAttachments.UserLastModified = HttpContext.Current.User.Identity.Name drAttachments.DateLastModified = Convert.ToDateTime(ViewState.Item("PresentDate")) Dim content() As [byte] = New Byte(filecontrol.PostedFile.ContentLength) {} drAttachments.FileData = content DstRequests1.Attachments.AddAttachmentsRow(drAttachments) </code> I know there is a way in the web.config file to increase the size limit of the file attachment. Do you happen to know what it is? Thanks much....... Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
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.