I have a web application on godaddy shared hosting. Its a asp.net application. Everything working fine but when I upload some file it gives an error "Access to the path 'PATH' is denied."
I tried several ways like giving full permission to the folder in which I am uploading the file from godaddy control panel.
I also saw this post and tried to follow he said : http://forums.asp.net/t/1052417.aspx/1
But no help.
Can anyone suggest me whats wrong there. Its under IIS 7.
Follow this:
Source - 2
“Setting Directory Permissions with Windows Hosting Accounts”
http://support.godaddy.com/help/article/6481
You should ask your hosting provider for access permissions if it doesn't solve your problem.
Ref:
Removing Web Access to Directories on a Windows Hosting Account
Removing the "Anonymous Access" IIS Setting for that directory. The
result of removing this permission is that you can only access that
directory from with your hosting account or via FTP. You will not be
able to access the directory through any Web browser, regardless of
whether you are knowledgeable of the hosting account user name and
password.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
protected void BindGrid()
{
string[] filePaths = Directory.GetFiles(Server.MapPath("~/images/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/images/") + FileUpload1.FileName);
BindGrid();
}
else //enter code here
{
Response.Write("Please select file to upload");
}
}
protected void DownloadFile(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath));
Response.WriteFile(filePath);
Response.End();
}
protected void DeleteFile(object sender, EventArgs e)
{
string filePath = (sender as LinkButton).CommandArgument;
File.Delete(filePath);
BindGrid();
}
}