Implement multi-file upload in ASP.NET

xiaoxiao2021-03-06  61

Private bolean savefiles ()

{

// Get the File form element

HTTPFILECOLLECTION FILES = httpContext.current.Request.files;

Try

{

For (int idcount = 0; intcount

{

Httppostedfile postedfile = files [intcount];

String FileName, FileExtension;

// Get the file name

Filename = system.io.path.GetFileName (postedfile.filename);

IF (filename! = "")

{

// Get file name extensions

FileExtension = system.io.path.Getextension (filename);

/ / Can save files to different folders according to different extensions

// Note: You may want to modify anonymous write permission for your folder. PostedFile.saveas (System.Web.httpContext.current.Request.mAppath ("Upfiles /") FileName);

}

}

Return True;

}

Catch (System.exception EX)

{

Return False;

}

}

转载请注明原文地址:https://www.9cbs.com/read-82005.html

New Post(0)