Problem uploading file on server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinaypratap
    New Member
    • Apr 2010
    • 5

    Problem uploading file on server

    hi everybody,

    I am trying to upload a file on server using fileupload control in asp.net 3.5.
    On local machine code is working fine, but when uploaded on server, it gives
    exception as :
    Exception Access to the path 'D:\hostingcont \march2010\abc\ abc.com\www\att achments\abc.jp g' is denied.

    I tried to set permission on attachments folder to (777) but when doing this server responds unrecognized chmod.

    please help me as soon as possible
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Well first of all chmod is a Linux/Unix command that changes the permission settings. ASP.NET applications have to be hosted in a Windows environment...T here is no chmod command in Windows.

    The other thing is that you are trying to access a drive "D:\"....ar e you Sure that your application has access to this??

    Consider using the Server.MapPath( ) function to save your file into a folder within your web application instead of trying to access a drive that may or may not exist.

    -Frinny

    Comment

    • vinaypratap
      New Member
      • Apr 2010
      • 5

      #3
      Originally posted by Frinavale
      Well first of all chmod is a Linux/Unix command that changes the permission settings. ASP.NET applications have to be hosted in a Windows environment...T here is no chmod command in Windows.

      The other thing is that you are trying to access a drive "D:\"....ar e you Sure that your application has access to this??

      Consider using the Server.MapPath( ) function to save your file into a folder within your web application instead of trying to access a drive that may or may not exist.

      -Frinny
      hi Frinny,

      Thanks for reply, as you said I am using Server.MapPath( ), the location "D:\".. is generated when exception occurs, here is code:
      Code:
       if (fileUploadAttach.HasFile)
                          {
      
      
                             
                            string  strFileName = Path.GetFileName(fileUploadAttach.PostedFile.FileName);
      
                              
                              fileUploadAttach.PostedFile.SaveAs(Server.MapPath("~/attachments/"+strFileName));
                               
      
                          }
      please help how to resolve the problem
      thanks
      Last edited by Frinavale; May 20 '10, 01:11 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Are you the server administrator?

        If you aren't you will have to talk to the administrator and let them know that your application has to be allowed to write to a folder within your website.

        -Frinny

        Comment

        Working...