私は次のコードを使用しています:
<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="submit" />
</form>
と...
[HttpPost]
public ActionResult Index(HttpPostedFileBase file) {
if (file.ContentLength > 0) {
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}
ファイルをファイル システムに保存する代わりに、着信ファイルからバイナリ データを抽出して、イメージをデータベースにコミットできるようにします。これをサポートするには、コードにどのような変更を加えることができますか?