.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Upload the file into server

Posted By: Catherine     Posted Date: June 07, 2011    Points:5   Category :C#
Hi i would like upload the file into server. I am using upload control to browse the file when i press the submit button the file in the upload controller should go to my server. and i would like to validate the file name like this solution_week1_date. if the file name like this then one only the file should be uploaded. please tell code in csharp

Author: Sasi Prabhu             
Posted Date: June 07, 2011     Points: 20   

First check the filename and then save into the server.

string filename=fileupload1.filename.tostring();

Thanks & Regards,
Sasi Prabhu.
Author: Gowthammanju             
Posted Date: June 07, 2011     Points: 20   

Hi dude!

follow the following steps as

1) Create a Folder within your Application say "UploadHere" and use the following code to upload a file to that folder:

protected void Button1_Click(object sender, EventArgs e)
if (FileUpload1.HasFile)
string filepath = FileUpload1.PostedFile.FileName;
string serverdirectorypath = Server.MapPath("~/UploadHere/");
string serverfilepath = serverdirectorypath + FileUpload1.FileName;
Response.Write("File Uploaded Successfully.");

where FileUpload1 is the Uploaderfilecontrol name !.....

hence u find the solution!!!!!

Thanks & Regards,

Mark if the answer is true
Author: shiv chandra             
Posted Date: June 12, 2011     Points: 20   

protected void BtnUpload_Click(object sender, EventArgs e)
// To check fileupload control has file or not.
if (FileUpload1.HasFile)
// One more condition to check filename.
// Replace your actual condition with solution_week1_date
if(solution_week1_date == true)
// Now upload file.


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend