当前位置: 移动技术网 > IT编程>开发语言>.net > 图片上传

图片上传

2018年11月23日  | 移动技术网IT编程  | 我要评论

羞辱尤娜2,花魁女帝txt,男人不难嫁主题曲

//上传图片
$("#file").change(function () {
var getimgdata = new formdata($("#formdata")[0]);
$.ajax({
url: "/weektest3view/uploadingfile",
contenttype: false,
processdata: false,
cache: false,
type: 'post',
data: getimgdata,
success: function (data) {
$("#displayimage").attr("src", data);
$("input[name=filename]").val(data);

}

});


});

view控制器:

/// <summary>
/// 上传图片
/// </summary>
/// <returns></returns>
[httppost]
public string uploadingfile()
{
httppostedfilebase getfile = request.files["file"];
if (getfile != null)
{
string getpath = server.mappath("~/image/");
if (!directory.exists(getpath))
{
directory.createdirectory(getpath);
}
string newpath = path.combine(getpath, getfile.filename);
getfile.saveas(newpath);
return "/image/" + getfile.filename;

}
else
{
return null;
}
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网