This is upload dedicated controller methods
public async TaskUploadFile ()
{
//Web root directory
String webRootPath=ConfigHelper. GetConfig (" ImgPath ");
Var date=Request;
Var files.=the Request Form. The files;
Long size=files. The Sum (f=& gt; F.L ength);
String shortTime=DateTime. Now. ToString (" yyyy/MM/dd ") + "/".
String filePhysicalPath=webRootPath + "/Content/GTP/made" + shortTime;//file path can be achieved by injecting IHostingEnvironment service object physical path of the root directory the root directory of the Web and content
. .
Using (var stream=new FileStream (filePhysicalPath + fileName, FileMode. Create))
{
Await the file. CopyToAsync (stream);
}
}
}
JObject job=new JObject ();
Job. The Add (new JProperty (" data ", jFile));
Return Ok (job. The ToString ());
}
Another controller is the method called such
private UpFileController _upFileController;
Public datacenterController (UpFileController UpFileController)
{
_upFileController=upFileController;
}
Public async TaskAddChord2 ()
{
Var t=await _upFileController. UploadFile ();
Return Ok (t.T oStr ());
}
CodePudding user response:
The general is a class instance into a Null, will appear in this kind of circumstance
CodePudding user response:
Directly set a breakpoint debugging your own Request. The Form,