Ask a Question related to ASP.NET Security, Design and Development.
-
el Bilo #1
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>
</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
-
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... -
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... -
[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... -
Uploading files in C#
why don't you examine the extension of the file being loaded. "Ian Walsh" <ianwalsh@hbosplc.com> wrote in message... -
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... -
Johan Normén NSQUARED2 #2
uploading files to a specified directory
That's strange.
What happens if you set the Everyone full access on this
folder? Same problem?
JN
denied>-----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 accesshas>error. I've checked to make sure that the ASP account->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
-
Larry #3
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
>
>> denied> >-----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> has> >error. I've checked to make sure that the ASP account> -> >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
-
Jacob Yang [MSFT] #4
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



Reply With Quote

