Upload error - Access to the path xxx is denied

R

Randy

Hello All,
I'm getting a strange error when trying to perform a file upload. Here's the
lines that uploads the file...

sSaveLocation = Server.MapPath("PFPDocs") + "\\" + fileName;
fileInput.PostedFile.SaveAs(sSaveLocation);

When it runs, I'm getting a "Access to the path xxx is denied" error. On the
server (Server 2003) I've given the ASP.NET and Everyone Full Control but
still I get the error. I've also given IUSR_machinename Full Control and I
still get the error.
One thing that is strange and I'm not sure if it's a problem, when the error
is reported in the dialog, it states that...
Access to the path "C:InetpubwwwrootPFPAppPFPDocsMyFile.xls" is denied
In the above error the "\"'s are not in there. I'm not sure if this is the
reason it won't upload the file or if it is a permissions thing.

Thanks
 
J

Juan T. Llibre

If you use C#, you must double the slashes
in order for one of them to show.

Check your fileName code and put double slashes "\\"
wherever you have a single slash "\".



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
R

Randy

Yes, I'm doing that...here's the line from below...
sSaveLocation = Server.MapPath("PFPDocs") + "\\" + fileName;
But, like I said, the error message doesn't show any slashes in it...strange
 
J

Juan T. Llibre

Randy, this works for me:

savePath.aspx
-------------------------------
<%@ Page Language="C#" %>

<script language = "C#" runat="server">
void Page_Load(Object Sender, EventArgs e)
{
String fileName = "a.txt";
String sSaveLocation = Server.MapPath("PFPDocs") + "\\" + fileName;
Label1.Text = sSaveLocation;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Retrieving a FilePath</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>

---000---

That returns : C:\Inetpub\wwwroot\test\PFPDocs\a.txt

I don't see why it shouldn't work for you.

Try running just that page (savePath.aspx), and see what it returns.
That should make your sleuthing easier.

Does the directory "wwwroot\PFPApp\PFPDocs" exist ?



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

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

Top