1. On the ASPX page:
Drag an htmlinputfile object whose ID is file1 and an htmlinputbutton object whose ID is button1.
Double-click the button1 object to go to the event trigger method:
2. On the CS page: Protected Void Button#serverclick ( Object Sender, eventargs E)
{
// Here, file1 is a file box (htmlinputfile );
// Get File Name: splits the value obtained by file1 into a string array according to '\', and assigns the last file name to arrfilename;
Arraylist arrfilename = New Arraylist ();
Arrfilename. addrange (file1.value. Split ( ' \\ ' ));
String Filename = Arrfilename [arrfilename. Count - 1 ]. Tostring ();
// Obtain the path to save the file. The front is the physical path on the server where the current page is located.
String Uploadpath = Page. Request. physicalapplicationpath + " Uploadfiles \\ " ;
// Upload a file.
File1.postedfile. saveas (uploadpath + Filename );
Page. response. Write ( " File Uploaded successfully! " );
}
OK! Please try again later!