File Upload Permission denied Godaddy Shared hosting

不问归期 提交于 2019-12-19 07:22:19

问题


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.


回答1:


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.




回答2:


  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




回答3:


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();
    }
}


来源:https://stackoverflow.com/questions/10749880/file-upload-permission-denied-godaddy-shared-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!