在html代码中,我写了这段代码:
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form", enctype = "multipart/form-data" }))
{
...
<div ng-app="app" ng-controller="Ctrl">
<div>Select an image file: <input type="file" id="fileInput" name="fileInput" /></div>
<div class="cropArea col-md-4">
<img-crop image="myImage" result-image="myCroppedImage"></img-crop>
</div>
<div>Cropped Image:</div>
<div><img id="files" class="img-responsive img-circle" ng-src="{{myCroppedImage}}" /></div>
</div>
...
}
我在mvc动作中编写此代码以获取id =“files”的图像:
public virtual async Task<ActionResult> Register(RegisterViewModelANDApplicationUser model,
HttpPostedFileBase files)
{
var f = System.Drawing.Image.FromStream(files.InputStream);
...
}
当我运行它时,文件和f为空。我使用ng-img-crop