Mac Browser upload problems

Discussion in 'ASP.NET / ASP.NET Core' started by annbransom, Dec 18, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have three pages that have file upload controls on them. The uploads are working fine on my PC, but they are not working for my client who is using Mac. Do I need to change something in the web config file? Here is my code:




    Dim FilePathConstant As String = Server.MapPath("XResourceFiles\")


    Dim file As Array = Split(FileUpload1.FileName, "\")


    Dim fi As New FileInfo("\XResourceFiles\" & file(file.Length - 1))


    If fi.Exists Then


    fi.Delete()


    End If


    FileUpload1.PostedFile.SaveAs(FilePathConstant & file(file.Length - 1))


    Dim sqlConn As SqlConnection = New SqlConnection(dbConn)


    Dim sqlCmd As SqlCommand = New System.Data.SqlClient.SqlCommand()


    Dim sqlAdapter As SqlDataAdapter = New SqlDataAdapter


    Dim Title As String


    Title = TitleTextBox.Text


    Title = Replace(Title, "'", "''")


    Dim Descrip As String


    Descrip = DescriptionTextBox.Text


    Descrip = Replace(Descrip, "'", "''")


    Descrip = Replace(Descrip, vbCrLf, "")





    With sqlCmd


    .Connection = sqlConn


    .CommandType = CommandType.Text


    .CommandText = "Insert into PDFs (Title, FileURL, Description) values ('" & Title & "', 'XResourceFiles\" & file(file.Length - 1) & "', '" & Descrip & "')"


    .Connection.Open()


    .ExecuteNonQuery()


    .Connection.Close()


    End With


    Response.Redirect("XAdminResources.aspx")


    The client is getting the following error:
    Could not find a part of the path
    'E:\web\annbransomc\htdocs\XResourceFiles\'.

    Description:
    An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details:
    System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\web\annbransomc\htdocs\XResourceFiles\'.
    Source Error:

    Line 51: End If
    Line 52:
    Line 53: FileUpload1.PostedFile.SaveAs(FilePathConstant & file(file.Length - 1))
    Line 54:
    Line 55: Dim sqlConn As SqlConnection = New SqlConnection(dbConn)
    Source File:
    E:\web\annbransomc\htdocs\XAdminResources.aspx.vb Line: 53
    Stack Trace:

    [DirectoryNotFoundException: Could not find a part of the path 'E:\web\annbransomc\htdocs\XResourceFiles\'.]
    System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2014544
    System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, System.IO.FileStream..ctor(String path, FileMode mode) +65
    System.Web.HttpPostedFile.SaveAs(String filename) +87
    XAdminResources.Button1_Click(Object sender, EventArgs e) in E:\web\annbransomc\htdocs\XAdminResources.aspx.vb:53
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
    Version Information:
    Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
     
  2. These 2 lines differ. one has the FilePathConstant, one doesn't.





    Dim fi As New FileInfo("\XResourceFiles\" & file(file.Length - 1))


    FileUpload1.PostedFile.SaveAs(FilePathConstant & file(file.Length - 1))

    output this to the browser... "FilePathConstant & file(file.Length - 1)", make sure you are getting the full filename.


    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page