Easily implement file upload in ASPX

xiaoxiao2021-03-06  213

Easily implement file upload in ASPX

It is very easy to implement file upload in ASPX, as follows:

private string upLoadFile (System.Web.UI.HtmlControls.HtmlInputFile tFile, string FilePath) {if (tFile.PostedFile.ContentLength> 0) {string strFileName = Path.GetFileName (tFile.PostedFile.FileName); tFile.PostedFile.SaveAs ( Filepath strfilename); return strfilename;} else {return "";}}

But there is a problem, if your accessory size is 4M, then the upload file will report an error, why is it wrong? The reason is that the ASPX default maxRequestLength is 4096KB is 4MB, we need to change the following settings in Web.config, of course the specific value Depending on the actual situation.

... "... ...Tem.WewexecutionTIMEOUT Unit Second

MaxRequestLength unit KB

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

New Post(0)