|
-
October 14th, 2009, 09:53 AM
#1
Error uploading file - Could not find a part of the path
I am having trouble uploading any file to the path in the error message below. Does anyone have any idea what the problem is. I did some research on this and most sites say that the permissions need Read/Write access for the asp.net user. I tried this and I still receiver the error. Here is the error:
For example Error saving file education_calendar.pdf System.IO.DirectoryNotFoundException: Could not find a part of the path "d:\inetpub\aopha\Uploads\". at System.IO.__Error.
Here is my code for the click event. I am not sure what is happening here:
Private Sub cmdUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpload.Click
If IsPostBack Then
Dim MyFileColl As HttpFileCollection = Request.Files
Dim MyPostedMember As HttpPostedFile = MyFileColl.Get("File1")
Dim MyFileName As String = MyPostedMember.FileName
If Not MyPostedMember Is Nothing Then
Try
Dim intFileNameLength As Integer = InStr(1, StrReverse(MyFileName), "\")
Dim strFileNameOnly As String = Mid(MyFileName, (Len(MyFileName) - intFileNameLength) + 2)
Dim RootPath As String = Server.MapPath("/")
'APPEND THE APPROPRIATE FOLDER
Dim tmpFolder As String = FileLoc.SelectedValue 'HttpContext.Current.Request.Form("FileLoc")
Dim WebFilePath As String = Server.MapPath(tmpFolder & strFileNameOnly) 'HttpContext.Current.Request.MapPath(tmpFolder & strFileNameOnly)
MyPostedMember.SaveAs(WebFilePath.ToString)
Dim LinkPath As String = WebFilePath.Replace(RootPath, "")
LinkPath = "/" & LinkPath.Replace("\", "/")
lblMessage.Text = "Successfully saved file: <a href=""" & LinkPath & """ target=""_blank"">" _
& tmpFolder & strFileNameOnly & "</a>"
'return the file to the opening window.
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
If Request.QueryString("retPath") = "link" Then
strScript += LinkPath
Else
strScript += strFileNameOnly
End If
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
Catch exc As Exception
lblMessage.Text = "Error saving file <b>" _
& File1.Value & "</b><br>" & exc.ToString()
End Try
End If
End If
End Sub
-
October 14th, 2009, 11:00 AM
#2
Re: Error uploading file - Could not find a part of the path
ANyone have any ideas on this please?
-
October 14th, 2009, 05:50 PM
#3
Re: Error uploading file - Could not find a part of the path
IIS doesn't know about inetpub. Use RELATIVE addressing. .\images
-
October 15th, 2009, 10:18 AM
#4
Re: Error uploading file - Could not find a part of the path
I looked at my web.config which is what is setting the path and the inetpub folder is used in the web.config but not where it is calling to upload the paths. This is the configuration for UploadPaths in web.config:
<PCMS>
<UploadPaths>
<add key="General Uploads" value="/Uploads/"/>
<add key="Upload Images" value="/Uploads/images/"/>
<add key="Public Documents" value="/Uploads/PublicDocuments/"/>
<add key="PDF Files" value="/pdf_files/"/>
<add key="Sustaining Firm Images" value="/member_photos/"/>
</UploadPaths>
</PCMS>
I still receive the error. What am I doing wrong here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|