uploading files to a specified directory

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>
&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.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
 
J

Johan Normén NSQUARED2

That's strange.

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

JN
 
L

Larry

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
 
J

Jacob Yang [MSFT]

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
http://support.microsoft.com/default.aspx?scid=kb;en-us;323245

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 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top