File Upload Folder Permissions

Discussion in 'ASP .Net' started by Adam, Mar 23, 2010.

  1. Adam

    Adam Guest

    Hi, I am trying to create a very basic file upload page, where the uploaded
    file is placed into a folder on the server (but not in the web path, i.e.
    c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS server it works
    correctly, and uploads the files, but anonymous users when they click on the
    upload button, it just refreshes the page and doesn't do anything. When it
    works on the IIS server, the page displays upload successful, while from
    another workstation it just goes back to the upload file comment and removes
    the selected file from the fileupload control.

    Can anyone please provide any good resources or identify what security I
    need to put on the c:\uploads folder and what setting (account) I should set
    for the Application pool.

    Thanks in advance.
    Adam
    Adam, Mar 23, 2010
    #1
    1. Advertising

  2. On Mar 23, 1:25 am, "Adam" <> wrote:
    > Hi, I am trying to create a very basic file upload page, where the uploaded
    > file is placed into a folder on the server (but not in the web path, i.e.
    > c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS server it works
    > correctly, and uploads the files, but anonymous users when they click on the
    > upload button, it just refreshes the page and doesn't do anything.  When it
    > works on the IIS server, the page displays upload successful, while from
    > another workstation it just goes back to the upload file comment and removes
    > the selected file from the fileupload control.
    >
    > Can anyone please provide any good resources or identify what security I
    > need to put on the c:\uploads folder and what setting (account) I should set
    > for the Application pool.
    >
    > Thanks in advance.
    > Adam


    It seems that the access to c:\uploads is for local users (like you)
    only and you need to add an ASP.NET account. I think you have
    try..catch in your code and that's why you can't see the error when
    "nothing happens". Disable error catching and you will see the
    message.

    Hope this helps.
    Alexey Smirnov, Mar 23, 2010
    #2
    1. Advertising

  3. Adam

    James Parker Guest

    >
    >Hi, I am trying to create a very basic file upload page, where the uploaded
    >file is placed into a folder on the server (but not in the web path, i.e.
    >c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS server it works
    >correctly, and uploads the files, but anonymous users when they click on the
    >upload button, it just refreshes the page and doesn't do anything. When it
    >works on the IIS server, the page displays upload successful, while from
    >another workstation it just goes back to the upload file comment and removes
    >the selected file from the fileupload control.
    >
    >Can anyone please provide any good resources or identify what security I
    >need to put on the c:\uploads folder and what setting (account) I should set
    >for the Application pool.
    >
    >Thanks in advance.
    >Adam
    >
    >
    >


    I think this might help with your issue.

    http://learn.iis.net/page.aspx/140/understanding-the-built-in-user-and-group-accounts-in-iis-70/

    j1mb0jay

    -----------------------------------
    Posted @ http://www.dotnethelp.co.uk
    James Parker, Mar 23, 2010
    #3
  4. Adam

    Adam Guest

    Hi Alexex,

    Here is my code, which I have the try - catch statement in. It must be a
    permissions thing for it to work on the host machine, but not on any others?

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Button1.Click

    If Not FileUpload1.PostedFile Is Nothing And
    FileUpload1.PostedFile.ContentLength > 0 Then

    Dim fn As String =
    System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName)

    Dim SaveLocation As String = "c:\Uploads" & "\" & fn

    Try

    FileUpload1.PostedFile.SaveAs(SaveLocation)

    Response.Write("The file has been uploaded.")

    Catch Exc As Exception

    Response.Write("Error: " & Exc.Message)

    End Try

    Else

    Response.Write("Please select a file to upload.")

    End If

    "Alexey Smirnov" <> wrote in message
    news:...
    On Mar 23, 1:25 am, "Adam" <> wrote:
    > Hi, I am trying to create a very basic file upload page, where the
    > uploaded
    > file is placed into a folder on the server (but not in the web path, i.e.
    > c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS server it works
    > correctly, and uploads the files, but anonymous users when they click on
    > the
    > upload button, it just refreshes the page and doesn't do anything. When it
    > works on the IIS server, the page displays upload successful, while from
    > another workstation it just goes back to the upload file comment and
    > removes
    > the selected file from the fileupload control.
    >
    > Can anyone please provide any good resources or identify what security I
    > need to put on the c:\uploads folder and what setting (account) I should
    > set
    > for the Application pool.
    >
    > Thanks in advance.
    > Adam


    It seems that the access to c:\uploads is for local users (like you)
    only and you need to add an ASP.NET account. I think you have
    try..catch in your code and that's why you can't see the error when
    "nothing happens". Disable error catching and you will see the
    message.

    Hope this helps.
    Adam, Mar 23, 2010
    #4
  5. Adam

    Adam Guest

    OMG, i feel so silly. To test the upload from the remote computer I created
    a couple of text files without any content. Therefore, with my code
    checking content length, it didnt upload it as the content length was 0.

    Sorry people!. Thanks for your help though.

    "Adam" <> wrote in message
    news:4ba80a99$0$8754$...
    > Hi, I am trying to create a very basic file upload page, where the
    > uploaded file is placed into a folder on the server (but not in the web
    > path, i.e. c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS
    > server it works correctly, and uploads the files, but anonymous users when
    > they click on the upload button, it just refreshes the page and doesn't do
    > anything. When it works on the IIS server, the page displays upload
    > successful, while from another workstation it just goes back to the upload
    > file comment and removes the selected file from the fileupload control.
    >
    > Can anyone please provide any good resources or identify what security I
    > need to put on the c:\uploads folder and what setting (account) I should
    > set for the Application pool.
    >
    > Thanks in advance.
    > Adam
    >
    Adam, Mar 23, 2010
    #5
  6. On Mar 24, 12:02 am, "Adam" <> wrote:
    > OMG, i feel so silly. To test the upload from the remote computer I created
    > a couple of text files without any content.  Therefore, with my code
    > checking content length, it didnt upload it as the content length was 0.
    >
    > Sorry people!. Thanks for your help though.
    >
    > "Adam" <> wrote in message
    >
    > news:4ba80a99$0$8754$...
    >
    >
    >
    > > Hi, I am trying to create a very basic file upload page, where the
    > > uploaded file is placed into a folder on the server (but not in the web
    > > path, i.e. c:\uploads and not c:\inetpub\wwwroot\uploads). On the IIS
    > > server it works correctly, and uploads the files, but anonymous users when
    > > they click on the upload button, it just refreshes the page and doesn't do
    > > anything.  When it works on the IIS server, the page displays upload
    > > successful, while from another workstation it just goes back to the upload
    > > file comment and removes the selected file from the fileupload control.

    >
    > > Can anyone please provide any good resources or identify what security I
    > > need to put on the c:\uploads folder and what setting (account) I should
    > > set for the Application pool.

    >
    > > Thanks in advance.
    > > Adam


    Glad that it works now for you! You can extend your code and check the
    size. Makes sense I think.
    Alexey Smirnov, Mar 24, 2010
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay
    Replies:
    2
    Views:
    750
    Brock Allen
    Apr 5, 2005
  2. Kapil via DotNetMonster.com

    Folder and File Permissions

    Kapil via DotNetMonster.com, Apr 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    434
    Winista
    Apr 10, 2006
  3. Brian Watkins

    Directory FileSystemInfo file and folder permissions

    Brian Watkins, Nov 19, 2003, in forum: ASP .Net Security
    Replies:
    1
    Views:
    132
    Brian Watkins
    Nov 19, 2003
  4. Setting File & Folder Permissions

    , May 20, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    152
    Dominick Baier [DevelopMentor]
    May 20, 2005
  5. N. Quisitive
    Replies:
    0
    Views:
    131
    N. Quisitive
    Jan 17, 2006
Loading...

Share This Page