Closed 7make closed 5 years ago
Use Http-Multipart-Data-Parser.
int ChunkSize = 1024;
try
{
using (Stream input = ((HttpRequest)context.Request).Advanced.InputStream)
{
var parser = new HttpMultipartParser.MultipartFormDataParser(input);
var task= parser.GetParameterValue("Task");
var fullAnswer= parser.GetParameterValue("FullAnswer")
// Loop through all the files
foreach (HttpMultipartParser.FilePart file in parser.Files)
{
using (BinaryReader reader = new BinaryReader(file.Data, context.Request.ContentEncoding))
{
using (BinaryWriter output = new BinaryWriter(File.Open(file.FileName, FileMode.Create)))
{
byte[] chunk = reader.ReadBytes(ChunkSize);
while (chunk.Length > 0)
{
output.Write(chunk);
chunk = reader.ReadBytes(ChunkSize);
}
}
}
}
}
}
catch (Exception e)
{
}
Have any example to work multipart/form-data from request?
POST request