0
Я хочу, чтобы загрузить свои файлы в папку, какЗагрузить мои файлы в папку с помощью asp.net
FileUpload1.SaveAs(Server.MapPath("~/admin_file/") + FileUpload1.FileName);
здесь мое имя папки admin_file.
protected void BindGrid() {
string[] filePaths = Directory.GetFiles(Server.MapPath("~/admin_file/"));
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("~/admin_file/") + FileUpload1.FileName);
BindGrid();
}
else
{
//Response.Write("Please select file to upload");
string message = "alert('Please select file to upload!')";
ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
}
}
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);
string message = "alert('Deleted Successfully!')";
ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
BindGrid();
}
Эта программа успешно выполняется в локальной системе. Когда я публикую эту программу GoDaddy не поддерживает так кто-нибудь сказать, как дать этому пути
иначе отправить письмо [email protected]
Что ошибки (s) вы получаете? –
Звучит как проблема с разрешением каталога с Godaddy. Ознакомьтесь с этим сообщением, чтобы узнать, как изменить настройки конфиденциальности в вашем каталоге admin_file ... http://stackoverflow.com/questions/10749880/file-upload-permission-denied-godaddy-shared-hosting – Scotty