<div class='imgOuter addImgBtn l_canshu' id='ImagePath1' value=''>
  <img src="../Images/AddI.gif" id="imgg" alt="Alternate Text" />
  <form action="@UploadURL" method="post" enctype="multipart/form-data" id="user_head_form11">
    <input type="file" class="bbbb" id="qdctvfile11" name="qdctvfile" onchange="eventStart(this);" />
    <input type="hidden" id="redirectUrl" name="redirectUrl" value="http://@(System.Configuration.ConfigurationManager.AppSettings["UrlHasPort"])/CommonData/Callback" />
    <input type="hidden" id="hidImg1" value="@Model.themePicUrl" />
    <input type="hidden" name="type" value="" />
  </form>
  <dd class="cccc" id="cccc1" style="display: none">上传中.....</dd>
</div>
.zImagesUploadBox {
width: 961px;
height: 110px;
padding: 15px 20px 0;
} .imgOuter {
float: left;
position: relative;
width: 168px;
height: 108px;
border: 1px solid #ccc;
margin-right: 12px;
} .imgOuter p.btnsBox {
display: none;
position: absolute;
left: -1px;
bottom: 7px;
width: 142px;
height: 26px;
padding: 0 14px;
z-index: 2;
} .imgOuter p.btnsBox a.deleteBtn {
float: right;
width: 68px;
height: 26px;
background: url("../Images/z_addImagesBtn_02.gif") 0 bottom no-repeat;
} .imgOuter p.btnsBox a.bigImg {
float: left;
width: 68px;
height: 26px;
background: url("../Images/z_addImagesBtn_02.gif") no-repeat;
} .imgOuter p.mask {
display: none;
position: absolute;
left: -1px;
top: -1px;
width: 170px;
height: 110px;
background: #000;
opacity: 0.5;
filter: alpha(opacity=50);
z-index: 1;
} .imgOuter img {
display: block;
} input {
outline: none;
} .addImgBtn {
float: left;
width: 160px;
height: 90px;
cursor: pointer;
opacity: 100; background-size: 100% auto;
}
.bbbb{
cursor: pointer;position: absolute;right: 0;top: 0;opacity: 0;filter:alpha(opacity=0);height: 90px;width: 160px;
} .cccc {
position: absolute;
background: #000;
opacity: 0.5;
width: 160px;
height: 90px;
text-align: center; padding: 40px;
color: #fff;
}
.addImgLayer {
left: 2px;
top: -108px;
width: 175px;
position: relative;
display: none;
} em {
left: 0px;
top: 5px;
font-style: normal;
position: absolute;
font-size: 14px;
line-height: 26px;
padding: 0 0 0 0;
}
.l_canshu div i{ position:absolute; right:5px; top:3px; width:14px; height:14px; background:url(../Scripts/addResource/img/l_InnercloseImg.png) no-repeat; z-index:999; cursor:pointer;}

  

function eventStart(obj) {
var fileLength = getFileSize(obj);
if (fileLength < 1.5 * 1024 * 1024) {
$("#user_head_form11").submit();
}
else {
bootbox.alert({
size: 'small',
message: "请上传1.5M以内的图片文件!",
title: "提示",
callback: function () {
}
})
return false;
}
}
function getFileSize(obj) {
var objValue = obj.value;
if (objValue == "") return;
var fileLenth = -1;
try {
//对于IE判断要上传的文件的大小
var fso = new ActiveXObject("Scripting.FileSystemObject");
fileLenth = parseInt(fso.getFile(objValue).size);
} catch (e) {
try {
//对于非IE获得要上传文件的大小
fileLenth = parseInt(obj.files[0].size);
} catch (e) {
fileLenth = -1;
}
}
return fileLenth;
}
$(document).ready(function () {
$("#user_head_form11").ajaxForm({
iframe: true,
beforeSerialize: function () {
var filepath = $("#qdctvfile11").val()
var extStart = filepath.lastIndexOf(".");
var ext = filepath.substring(extStart, filepath.length).toUpperCase();
if (ext != ".PNG" && ext != ".JPG") {
bootbox.alert({
size: 'small',
message: "图片仅支持png,jpg格式",
title: "提示",
callback: function () {
}
})
$("#qdctvfile11").val("");
return false;
}
//$("#cccc1").show();
$("#imgg").attr("src", "../Images/11.png");
$("#hiddenImg").val(1);
},
success: function (data) {
data = JSON.parse(data);
$("#hiddenImg").val("");
$("#cccc1").hide();
if (data.code == "OK") {
$("#ImagePath1").attr("value", "1");
$("#hidImg1").val(data.originalImgUrl);
$("#imgg").attr("src", data.thumpImgUrl);
$("#themePicMd5").val(data.md5Abstract);
}
}
});//end ajaxForm });

  使用ajaxForm上传图片可以直接上传到接口上没有必要用自己后台做为中转

C#使用ajaxForm进行上传图片的更多相关文章

  1. ajax上传图片 jquery插件 jquery.form.js 的方法 ajaxSubmit; AjaxForm与AjaxSubmit的差异

    先引入脚本  这里最好是把jquery的脚本升级到1.7 <script src="js/jquery-1.7.js" type="text/javascript& ...

  2. 手机端上传图片及java后台接收和ajaxForm提交

    有很多微信开发的项目在手机端需要传图片,但是又不想调用微信的上传图片接口,于是采取了如下做法: 使用ajaxForm提交文件所需js:jquery.form.js 页面代码: <%@ page ...

  3. C# AJAXform上传图片

     前台: @{    Layout = null;} <!DOCTYPE html> <html><head>    <meta name="vie ...

  4. 异步上传图片,光用jquery不行,得用jquery.form.js插件

    异步上传图片,光用jquery不行,得用jquery.form.js插件,百度一下下载这个插件,加jquery,引入就可以了 <form id="postbackground" ...

  5. 基于ASP.Net +easyUI框架上传图片,实现图片上传,提交表单

    <body> <link href="../../Easyui/themes/easyui.css" rel="stylesheet" typ ...

  6. 博客使用BOS上传图片

    1.博客平台的选定 从大学开始做个人主页算起,最开始是使用html,CSSS写简单的页面,后面大学毕业之后接触到了WordPress,就开始用WordPress搭建网站.现在还维护着一个农村网站.ht ...

  7. nodejs利用ajax实现网页无刷新上传图片

    nodejs利用ajax实现网页无刷新上传图片 标签(空格分隔): nodejs 通常情况下上传图片是要通过提交form表单来实现的,但是这又不可避免的产生了网页转. 利用ajax技术和FormDat ...

  8. -Android -线程池 批量上传图片 -附php接收代码

    (出处:http://www.cnblogs.com/linguanh/) 目录: 1,前序 2,类特点 3,用法 4,java代码 5,php代码 1,前序 还是源于重构,看着之前为赶时间写着的碎片 ...

  9. iOS 原生HTTP POST请求上传图片

    今天项目里做一个上传图片等个人信息的时候,使用了第三方AFNetworking - (AFHTTPRequestOperation *)POST:(NSString *)URLString param ...

随机推荐

  1. Service Provider模式

    参考文章:[http://blog.csdn.net/zl3450341/article/details/7227197] Service Interface:服务接口,将服务通过抽象统一声明,供客户 ...

  2. NUC_HomeWork1 -- POJ1068

    A - Parencodings Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Su ...

  3. H

    很爽的一局,打了70分钟,还刷新了我的最高击杀记录.打完出来一看居然是H局,第一次在H局里打出不错的表现诶.好像找人说一说,可惜并没有谁听,以前的朋友也不在了,还是算了,自己心里慢慢发霉去吧. 这局末 ...

  4. CentOS 6.6 下配置软RAID5

    在虚拟机中增加4块5G的硬盘 安装依赖包 yum install -y parted mdadm 查看一下硬盘信息fdisk -l

  5. ihhh题解

    10分做法: 由于空间卡得紧,所以给了10分暴力分0.0所以大家很容易就知道暴力就是线段树套ac自动机辣时间:$O((\sum |qSi| + \sum |nSi|)*log Q)$空间:$O((\s ...

  6. 【BZOJ】1856: [Scoi2010]字符串

    http://www.lydsy.com/JudgeOnline/problem.php?id=1856 题意:把n个1和m个0组成字符串,要求在组成的字符串中,任意的前k个字符1的个数不能少于0的个 ...

  7. HDU-1231 简单dp,连续子序列最大和,水

    1.HDU-1231 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231 3.总结:水 题意:连续子序列最大和 #include<iostre ...

  8. lua日期与时间操作

    os.date("%Y%m%d%H%M%S", os.time()) <== 20160405141211 yyyyMMddHHmmss os.time()          ...

  9. MVVMLight Messenging

    Basically there are two possible ways to send a message, first using an overload of the RaisePropert ...

  10. [LintCode] Candy 分糖果问题

    There are N children standing in a line. Each child is assigned a rating value. You are giving candi ...