我正在为我的项目使用Adobe Creative SDK图片编辑器和.net。当我编辑图像时,只有<“ img”>会发生变化,但是我正在发送<“ input file”>。我尝试了两种方法,首先将数据发送到<“输入文件”>,然后再发送到控制器。但是我没有。辅助文件直接直接“ ”发送到控制器,但再次无法工作。
@using (Html.BeginForm("Save", "Tweet", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>TweetModel</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Content, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="row">
<div class="col-md-10">
<input id="click-upload" name="file" type="file">
<div id="drop-area">
<p>Drop an image here!</p>
<p>(or click to upload)</p>
</div>
<img id="editable-image" onclick="read()" class="img-responsive">
</div>
</div>
<div class="col-md-12">
<button>Gönder</button>
</div>
}`
<script type="text/javascript">
function read()
{
var c = document.getElementById("editable-image");
document.getElementById("click-upload").innerHTML = c;
alert(document.getElementById("click-upload").size);
}
</script>
public ActionResult Save(Tweet tweetModel)
{
WebImage file = WebImage.GetImageFromRequest();
tweetModel.UserId = Convert.ToInt32(Session["UserId"]);
if (tweetModel.UserId > 0)
{
if (file.FileName !=null)
{
// code for saving the image file to a physical location.
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Uploads/Image"), fileName);
file.Save(path);
// prepare a relative path to be stored in the database and used to display later on.
path = Url.Content(Path.Combine("~/Uploads/Image", fileName));
// save to db
tweetModel.Image = path;
}
CreateOrder(tweetModel);
}
return RedirectToAction("Index");
}