string m_file = AsyncFileUpload1.PostedFile.FileName;
AsyncFileUpload1.SaveAs(Server.MapPath("Currency/" + m_file));
But File not save at target folder? What's Problem ?
But File not save at target folder? What's Problem ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Jun 8, 2011, 6:13 AM
Praneeth KumarPosted Jun 8, 2011, 3:18 AM
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e) {
if (AsyncFileUpload1.HasFile) {
string strPath = MapPath("~/Currency/") + Path.GetFileName(AsyncFileUpload1.PostedFile.FileName);
AsyncFileUpload1.SaveAs(strPath);
}
}
}
Aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Jiteendra SampathiraoPosted Jun 8, 2011, 2:45 AM
AsyncFileUpload1.SaveAs(Server.MapPath("~/Currency/" + m_file));
or
AsyncFileUpload1.SaveAs(Server.MapPath("../Currency/" + m_file));
OR
Check the in download file:
Sandeep ShekhawatPosted Jun 8, 2011, 2:43 AM
When i clicked on rar file it display error.I could not download at my end. Please copy paste code here for me.
Praneeth KumarPosted Jun 8, 2011, 2:33 AM
Sandeep ShekhawatPosted Jun 8, 2011, 2:17 AM
(i)Does the folder have rights to save?
YES,Folder at local machine it has permission of save and access.
(ii)Is the path correct which you have given for saving?
YES,Currency Folder is in root directory and my web content form is also in root directory.
(iii)I hope you are not using Ajax Update panel as I remember in the update panel AsyncFileUpload1.PostedFile.FileName usually comes as empty. If that is the case add a postback trigger for the button.
I am using Master Page and Content Page ,Master Page have ScriptManager and Content page contain Update Panel.Button and AsyncFileUpload controls are in Update Panel so i think i not need add to postback trigger.
AsyncFileUpload1.PostedFile.FileName has same string that i want it is not empty.
I think now u can help me.
Thanx
Praneeth KumarPosted Jun 8, 2011, 2:08 AM
Is the path correct which you have given for saving?
I hope you are not using Ajax Update panel as I remember in the update panel AsyncFileUpload1.PostedFile.FileName usually comes as empty. If that is the case add a postback trigger for the button.