File Upload Permission denied Godaddy Shared hosti

2020-03-20 14:10发布

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.

3条回答
叛逆
2楼-- · 2020-03-20 14:46
  1. Open "File Manager"
  2. Navigate to folder and hover over it
  3. Click little "down" arrow towards right edge of "Name" column (see image)
  4. Click "Change Permissions"
  5. Select user (you'll most likely want to use "Plesk IIS Worker Process Identity Account" if you're doing file uploads through your site) and set permissions as needed

enter image description here

查看更多
放荡不羁爱自由
3楼-- · 2020-03-20 14:47
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();
    }
}
查看更多
Emotional °昔
4楼-- · 2020-03-20 14:53

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.

查看更多
登录 后发表回答