Upload file to server
-
Hai all, I need to upload file to server and i am using input file to upload the file, my problem is postedfile.filename is always null. I have tried using updatepanel and had same problem. Can anyone help me.
File upload doesn't work under
UpdatePanel
ByDefault. you need to setPostBackTrigger
in<Triggers>
Section ofUpdatePanel
by which you can force a completePostBack
.Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
-
File upload doesn't work under
UpdatePanel
ByDefault. you need to setPostBackTrigger
in<Triggers>
Section ofUpdatePanel
by which you can force a completePostBack
.Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
-
Make sure you are using it under
!Page.IsPostBack
Condition.Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
-
Make sure you are using it under
!Page.IsPostBack
Condition.Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
Actually in my form i had a ultrawebgrid and a template column as button, when click the button by client side the value ll be assign to the fileupload control and when i click the upload button the file should be uploaded . My ultrawebgrid and upload button is inside refresh panel and fileupload is outside the refreshpanel.
-
Actually in my form i had a ultrawebgrid and a template column as button, when click the button by client side the value ll be assign to the fileupload control and when i click the upload button the file should be uploaded . My ultrawebgrid and upload button is inside refresh panel and fileupload is outside the refreshpanel.
-
Hai all, I need to upload file to server and i am using input file to upload the file, my problem is postedfile.filename is always null. I have tried using updatepanel and had same problem. Can anyone help me.
-
You can't assign the filename in an upload control with javascript. That is a security feature. Otherwise a web site could tell the browser to upload things like password files and steal data.
T M Gray wrote:
You can't assign the filename in an upload control with javascript
He's probably not asking of assigning values rather He wants value inside.
Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
-
T M Gray wrote:
You can't assign the filename in an upload control with javascript
He's probably not asking of assigning values rather He wants value inside.
Regards, Hiren. "The more we give of anything, the more we shall get back." - Grace Speare (you can consider this quote while giving vote also) Microsoft Dynamics CRM
-
Yes i need only the value , in client side i am getting the path value but in server side it is null.
string fn = Path.GetFileName(inputFile.PostedFile.FileName);
string savepath = Server.MapPath("Exports") + "\\" + fn;//Exports is a folder where u will save all the posted files...
inputFile.PostedFile.SaveAs(savepath);//makes a copy of the file onto your server...
string[] lines = File.ReadAllLines(savepath);//will read all lines from a filefor (int i = 0; i < lines.Length; i++)//loop through all the lines in your file
{
//do everything you want with the file contents
}; Hope that helps.. Later!
-
string fn = Path.GetFileName(inputFile.PostedFile.FileName);
string savepath = Server.MapPath("Exports") + "\\" + fn;//Exports is a folder where u will save all the posted files...
inputFile.PostedFile.SaveAs(savepath);//makes a copy of the file onto your server...
string[] lines = File.ReadAllLines(savepath);//will read all lines from a filefor (int i = 0; i < lines.Length; i++)//loop through all the lines in your file
{
//do everything you want with the file contents
}; Hope that helps.. Later!
-
It works, if u need more help hala at me...
-
It works, if u need more help hala at me...
-
You might want to take a look at what exactly you are doing in your Page_Load event...you could be reseting the values of your controls... Put the code above in a method e.g.:
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
UploadFile();//call your method here...
}//or put this ispostback check in the click event of the control/button that will do the uploading process
}protected void UploadFile()
{
//put the code i gave you here...
}