后台

[HttpPost]
public ActionResult uploadfile(HttpPostedFileBase pic)
{
string warning = "";
string files = Server.MapPath(pic.FileName);
string filename = files.Remove(files.LastIndexOf("\\") - 4) + "images\\" + pic.FileName;
string watchname = files.Remove(files.LastIndexOf("\\") - 4) + "images\\" + "f244ce6f-eb3a-46d6-aa70-049db0d4dda3.png";

pic.SaveAs(filename);//保存上传的地址
// 地址 水印地址
string WarkUrl = WatherHelper.makewatermark(filename, watchname, WaterType.Center, files.Remove(files.LastIndexOf("\\") - 4) + "images\\", ImageType.JPEG, FileCache.Delete, out warning);
return Content(WarkUrl);
}

前台

<div>
<form action="/show/tu" enctype="multipart/form-data" method="post" >
<input id="File1" type="file" name="Exc" />
<input id="Submit1" type="submit" value="上传" onclick="yang()"/>
</form>
<img id="totop" />
</div>
<script>
function yang()
{
$("#yang").ajaxSubmit({
success: function (text)
{
$("#totop").attr("src", text);

}
})

}

</script>

posted on 2017-11-23 11:07  过客s  阅读(107)  评论(0编辑  收藏  举报