When the Aspx page receives a file stream, it becomes a pony that supports uploading arbitrary files.
Upload2.aspx
Using System;
Using System. Collections. Generic;
Using System. IO;
Using System. Text;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Public partial class upload2: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
If (Request. QueryString. Count> 0)
{
String filename = Request. QueryString ["filename"];
Encoding myEncoding = Encoding. GetEncoding ("UTF-8 ");
// Receives the transmitted data stream
Stream resStream = Request. InputStream;
Byte [] filecontent = new byte [resStream. Length];
// Read data streams into byte Arrays
ResStream. Read (filecontent, 0, filecontent. Length );
// Convert the array to string for base64 Conversion
String a = myEncoding. GetString (filecontent );
// Decrypt the string read base64 to the byte array
// Byte [] filecontent2 = Convert. FromBase64String ();
// Write directory
File. WriteAllBytes (Server. MapPath ("~ /Upload/"+ filename), filecontent );
// Return Value
// Response. Write ("OK ");
Response. End ();
}
}
}