E
el Bilo
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.AppSettings
("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
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.AppSettings
("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