<div class="form-group"> <label class="col-sm-6 control-label" for="inputfile">维修照片上传</label> <div class="col-sm-6 "> <div style="background:url(../../fonts/add.png) no-repeat;width:151px;height:150px;float:left;" id="div1"> <input type="file" accept="image/*" id="file" class="selectinput" style="width:151px;height:150px;opacity:.01"> </div> </div> </div>
$("#file").localResizeIMG({
width: 400,
//height: 200,
quality: 1,
success: function (result) {
var img = new Image();
img.src = result.base64;
//$("body").append(img);
$("#odd").append(img); //呈现图像(拍照結果)
$.ajax({
url: "/Home/UploadImg",
type: "POST",
data: { "formFile": result.clearBase64, "RepairNum": $('#RepairNum').val()},
dataType: "HTML",
timeout: 1000,
error: function () {
alert("ajax Error");
},
success: function (data) {
//alert("Uploads success~")
}
});
}
});
[HttpPost]
public ActionResult UploadImg()
{
var file = Request["formFile"];
var id = Request["RepairNum"];
string fileName = "1.jpeg";
string filePath = Server.MapPath("~/Upload/" + fileName);
try
{
Base64StringToImage(file, filePath);
//upImg.SaveAs(filePhysicalPath);
//Session["ImgPath"] = path;
//Base64StringToImage(file,);
return Content("上传成功");
}
catch
{
return Content("上传异常 !");
}
}
protected void Base64StringToImage(string strbase64, string filepath)
{
try
{
byte[] arr = Convert.FromBase64String(strbase64);
MemoryStream ms = new MemoryStream(arr);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);
//bmp.Dispose();
bmp.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Close();
}
catch (Exception ex)
{
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有