<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. WPF之依赖属性

    Introduction When you begin to develop appliations with WPF, you will soon stumble across Dependency ...

  2. HDU-2844 Coins(多重背包)

    Problem Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. On ...

  3. Linux 启动项介绍

    1. init进程 非内核进程中第一个被启动运行的,因此它的进程编号PID的值总是1.init读它的配置文件/etc/inittab,决定需要启动的运行级别(Runlevel,分别由0到6的整数表示) ...

  4. java中的IO操作总结

    一.InputStream重用技巧(利用ByteArrayOutputStream) 对同一个InputStream对象进行使用多次. 比如,客户端从服务器获取数据 ,利用HttpURLConnect ...

  5. QWord2vec:word2vec移植版+GUI

    序 Word2Vec原生是不支持Windows的,索性就用Qt移植了一下. 大概做了下面几件事. ①替换LinuxAPI的pthread为QThread. ②取消了posix_memalign(),内 ...

  6. Codeforces Round #251 (Div. 2) A - Devu, the Singer and Churu, the Joker

    水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; ...

  7. ACM: Copying Data 线段树-成段更新-解题报告

    Copying Data Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description W ...

  8. JavaScript基础学习篇

    1.alert消息弹出框 alert(字符串或变量); 消息对话框通常可以用于调试程序. 与document.write 相似. 2.确认:confirm消息对话框 confirm(弹出时要显示的文本 ...

  9. 【JAVA】通过公式字符串表达式计算值,网上的一种方法

    public class Test {    public static void main(String[] args) {     SimpleCalculator s=new SimpleCal ...

  10. java开发_模仿百度文库_OpenOffice2PDF_注意事项

    在模仿百度文库的操作过程中,有很多朋友反映出来的一些问题,是我想起了写这篇blog. 主要是让大家在做的过程中注意一些东西,否则达不到想要的效果. 第一步:我们先从 java开发_模仿百度文库_Ope ...