uploading files to a specified directory

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default uploading files to a specified directory

    In my application I would like to to be able to upload
    files to a specified directory on the server. I specify
    the files in the app settings section of the web.config
    file.

    When I try to save the file though I get an access denied
    error. I've checked to make sure that the ASP account has
    full privleges for the directory in question but I still
    get the same error.

    Here's the code I'm using:

    <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="imgEdit.aspx.vb" Inherits="ads_svrc.imgEdit"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <HTML>
    <HEAD>
    <title>imgEdit</title>
    <meta name="GENERATOR" content="Microsoft
    Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE"
    content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript"
    content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body>
    <form id="Form1" enctype="multipart/form-
    data" runat="server">
    <P>
    Select File to Upload:
    <input id="File1" type="file" runat="server">
    </P>
    <P>
    <asp:Label id="lblDebug"
    runat="server">Label</asp:Label></P>
    <p>
    <input type="button"
    id="BtnUpload" value="Upload" runat="server">
    </p>
    &nbsp;
    </form>
    </body>
    </HTML>

    ----------------------------------------------------------
    Dim tempPath As String

    Private Sub Page_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    If Not IsNothing(Session("tempPath")) Then
    tempPath = Session("tempPath")
    Else
    tempPath =
    System.Configuration.ConfigurationSettings.AppSett ings
    ("tempPath")
    Session("tempPath") = tempPath
    Me.lblDebug.Text = tempPath
    End If

    End Sub

    Private Sub BtnUpload_ServerClick(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    BtnUpload.ServerClick
    If Not IsNothing(File1.PostedFile) Then
    Try
    File1.PostedFile.SaveAs(tempPath)
    Catch ex As Exception
    Me.lblDebug.Text = ex.Message.ToString
    End Try
    End If
    End Sub


    Any suggestion as to what I've missed?

    -Larry
    el Bilo Guest

  2. Similar Questions and Discussions

    1. uploading a Directory
      Hi All, I am new to Flash. I want to upload an directory into a Web server. Will it be possible using Flash. If possible. Could you some...
    2. Problems: uploading files have Chinese named files
      Hi everyone, I try to upload file by using asp.net, code like that: <script language="VB" runat="server"> Sub Upload(Source As Object, e As...
    3. [PHP] Uploading files via SSH
      Google for "Failed to scan directories. Error 6" (including quotes). First result is the ssh.com faq, which has a link to...
    4. Uploading files in C#
      why don't you examine the extension of the file being loaded. "Ian Walsh" <ianwalsh@hbosplc.com> wrote in message...
    5. Uploading Files - help please
      When you use: <Input ID="ImageUpload" Type="File" visible="false" RunAt="Server"> Is their any way you can make a starting value appear inside...
  3. #2

    Default uploading files to a specified directory

    That's strange.

    What happens if you set the Everyone full access on this
    folder? Same problem?

    JN

    >-----Original Message-----
    >In my application I would like to to be able to upload
    >files to a specified directory on the server. I specify
    >the files in the app settings section of the web.config
    >file.
    >
    >When I try to save the file though I get an access
    denied
    >error. I've checked to make sure that the ASP account
    has
    >full privleges for the directory in question but I still
    >get the same error.
    >
    >Here's the code I'm using:
    >
    ><%@ Page Language="vb" AutoEventWireup="false"
    >Codebehind="imgEdit.aspx.vb" Inherits="ads_svrc.imgEdit"%
    >
    ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    >Transitional//EN">
    ><HTML>
    > <HEAD>
    > <title>imgEdit</title>
    > <meta name="GENERATOR" content="Microsoft
    >Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE"
    >content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript"
    >content="JavaScript">
    > <meta name="vs_targetSchema"
    >content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <body>
    > <form id="Form1" enctype="multipart/form-
    >data" runat="server">
    > <P>
    > Select File to Upload:
    ><input id="File1" type="file" runat="server">
    > </P>
    > <P>
    > <asp:Label id="lblDebug"
    >runat="server">Label</asp:Label></P>
    > <p>
    > <input type="button"
    >id="BtnUpload" value="Upload" runat="server">
    > </p>
    >
    > </form>
    > </body>
    ></HTML>
    >
    >---------------------------------------------------------
    -
    > Dim tempPath As String
    >
    > Private Sub Page_Load(ByVal sender As System.Object,
    >ByVal e As System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    > If Not IsNothing(Session("tempPath")) Then
    > tempPath = Session("tempPath")
    > Else
    > tempPath =
    >System.Configuration.ConfigurationSettings.AppSet tings
    >("tempPath")
    > Session("tempPath") = tempPath
    > Me.lblDebug.Text = tempPath
    > End If
    >
    > End Sub
    >
    > Private Sub BtnUpload_ServerClick(ByVal sender As
    >System.Object, ByVal e As System.EventArgs) Handles
    >BtnUpload.ServerClick
    > If Not IsNothing(File1.PostedFile) Then
    > Try
    > File1.PostedFile.SaveAs(tempPath)
    > Catch ex As Exception
    > Me.lblDebug.Text = ex.Message.ToString
    > End Try
    > End If
    > End Sub
    >
    >
    >Any suggestion as to what I've missed?
    >
    >-Larry
    >.
    >
    Johan Normén NSQUARED2 Guest

  4. #3

    Default Re: uploading files to a specified directory

    Same thing. The error message from the exception says that access to that
    directory is denied.

    "Access to the path "d:\wwwroot\Development\ads-svrc\temp" is denied."

    -Larry


    "Johan Normén NSQUARED2" <m@m.se> wrote in message
    news:15ea01c38418$f5483ee0$a401280a@phx.gbl...
    > That's strange.
    >
    > What happens if you set the Everyone full access on this
    > folder? Same problem?
    >
    > JN
    >
    >
    > >-----Original Message-----
    > >In my application I would like to to be able to upload
    > >files to a specified directory on the server. I specify
    > >the files in the app settings section of the web.config
    > >file.
    > >
    > >When I try to save the file though I get an access
    > denied
    > >error. I've checked to make sure that the ASP account
    > has
    > >full privleges for the directory in question but I still
    > >get the same error.
    > >
    > >Here's the code I'm using:
    > >
    > ><%@ Page Language="vb" AutoEventWireup="false"
    > >Codebehind="imgEdit.aspx.vb" Inherits="ads_svrc.imgEdit"%
    > >
    > ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    > >Transitional//EN">
    > ><HTML>
    > > <HEAD>
    > > <title>imgEdit</title>
    > > <meta name="GENERATOR" content="Microsoft
    > >Visual Studio .NET 7.1">
    > > <meta name="CODE_LANGUAGE"
    > >content="Visual Basic .NET 7.1">
    > > <meta name="vs_defaultClientScript"
    > >content="JavaScript">
    > > <meta name="vs_targetSchema"
    > >content="http://schemas.microsoft.com/intellisense/ie5">
    > > </HEAD>
    > > <body>
    > > <form id="Form1" enctype="multipart/form-
    > >data" runat="server">
    > > <P>
    > > Select File to Upload:
    > ><input id="File1" type="file" runat="server">
    > > </P>
    > > <P>
    > > <asp:Label id="lblDebug"
    > >runat="server">Label</asp:Label></P>
    > > <p>
    > > <input type="button"
    > >id="BtnUpload" value="Upload" runat="server">
    > > </p>
    > >
    > > </form>
    > > </body>
    > ></HTML>
    > >
    > >---------------------------------------------------------
    > -
    > > Dim tempPath As String
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object,
    > >ByVal e As System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > > If Not IsNothing(Session("tempPath")) Then
    > > tempPath = Session("tempPath")
    > > Else
    > > tempPath =
    > >System.Configuration.ConfigurationSettings.AppSet tings
    > >("tempPath")
    > > Session("tempPath") = tempPath
    > > Me.lblDebug.Text = tempPath
    > > End If
    > >
    > > End Sub
    > >
    > > Private Sub BtnUpload_ServerClick(ByVal sender As
    > >System.Object, ByVal e As System.EventArgs) Handles
    > >BtnUpload.ServerClick
    > > If Not IsNothing(File1.PostedFile) Then
    > > Try
    > > File1.PostedFile.SaveAs(tempPath)
    > > Catch ex As Exception
    > > Me.lblDebug.Text = ex.Message.ToString
    > > End Try
    > > End If
    > > End Sub
    > >
    > >
    > >Any suggestion as to what I've missed?
    > >
    > >-Larry
    > >.
    > >

    Larry Guest

  5. #4

    Default Re: uploading files to a specified directory

    Hi Larry,

    Based on my research and experience, the following Knowledge Base article
    is useful to this issue:

    HOW TO: Upload a File to a Web Server in ASP.NET by Using Visual Basic .NET
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;323245[/url]

    This step-by-step article describes how to upload a file to a Web server by
    using Visual Basic .NET. In this article, you create an ASP.NET file
    (WebForm1.aspx) and its related code-behind file (WebForm1.aspx.vb) to
    upload files to a directory that is named Data.

    Please test this article on your side and check if the same problem still
    exists.

    I hope it helps.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C [url]www.microsoft.com/security[/url]
    This posting is provided "as is" with no warranties and confers no rights.

    Jacob Yang [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139