jQuery中的Ajax不能支持 input file 需要用ajaxupload.js但是先需要引入jQuery文件

<script src="__PUBLIC__/js/ajaxfileupload.js"></script>

HTML代码很简单:

input id="upfiles" class="upfiles" type="file" name="log" onchange="uploadImage();">

js代码:

      function uploadImage(){
$.ajaxFileUpload({
url:"{:U('User/uploadImage')}",
secureuri:false,
fileElementId:'upfiles',//file标签的id
dataType: 'json',//返回数据的类型
//data:{name:'logan'},//一同上传的数据
success: function (data, status) {
var obj = jQuery.parseJSON(data);
if (obj.code == "0") {
$(".upload-new-img").attr("src",obj.fileName);
}else{
alert($obj.msg);
}
}
});
}

  

移动端头像上传AJax input file的更多相关文章

  1. 通过Ajax方式上传文件(input file),使用FormData进行Ajax请求

    <script type="text/jscript"> $(function () { $("#btn_uploadimg").click(fun ...

  2. 上传文件 input file

    //-----前端文件------- form id="uploadForm" enctype="multipart/form-data"> <in ...

  3. jquery即时获取上传文件input file文件名

    截图:   代码: <input type="file" id="choosefile" style="display:none"/& ...

  4. 文件上传:input file FileReader

    js: window.onload = function () { var input = document.getElementById('input-file'), info = document ...

  5. python+selenium:解决上传文件<input type='file'>标签属性被css的visibility隐藏导致无法定位元素的问题

    要想上传文件,需要找到在HTML中<input type="file" />这个标签,有它就可以利用send_keys上传文件,不过这里的<input>元素 ...

  6. JAVA判断上传表单中file是否为空

    <form action="update.do"method="post" enctype="multipart/form-data" ...

  7. 通过winForm控制webForm的上传控件file的值

    文件上传是日常开发中经常遇到的,文件上传用的最多的当然是上传控件file了,一个form表单,其中有一点就是form表单的enctype属性设置为multipart/form-data,呵呵,这个在所 ...

  8. spring mvc 选中多文件同时上传(利用input元素的multiple属性)

    原文:http://m.blog.csdn.net/article/details?id=51351388 <!DOCTYPE html> <html> <head> ...

  9. 一个漂亮的上传按钮input[type=file]

    ;;} <div class="input-group xj-file xj-panel-top"> <span class="input-group- ...

随机推荐

  1. 通过pip安装模块

    环境:ubuntu,python2/3 命令: pip3 install ipy # 通过pip3给python3.x安装ipypip3 install --upgrade pip # 升级pippi ...

  2. linux操作系统基础

    计算机概述 1.计算机接收用户输入指令数据,经过cpu数据与逻辑单元运算处理后,产生或储存成有用的信息--->I/O设备+cpu+处理信息=计算机. 2.计算机五大单元:I/O单元 内存单元 c ...

  3. [字符哈希] POJ 3094 Quicksum

    Quicksum Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16488   Accepted: 11453 Descri ...

  4. python_bug

    with open('test.txt','r',encoding='utf8') as f: Exception:'encoding' is an invalid keyword argument ...

  5. ROS语音交互(四)接入图灵语义理解

    首先程序中会用到Json,curl 安装相应的库 $ sudo apt-get install libcurl3 libcurl4-openssl-dev$ sudo apt-get install ...

  6. python学习04——列表的操作

    笨办法学python第38节 如何创建列表在第32节,形式如下: 本节主要是讲对列表的操作,首先讲了 mystuff.append('hello') 的工作原理,我的理解是,首先Python找到mys ...

  7. 初步了解JPA

    想当初07.08年的时候,毕业之季,正思考着离开学校要去做什么工作.为了有一份薪资不错,可以长久发展,也正是自己喜欢的行业.于是乎决定投身于计算机行业.当年正是JAVA的火热时期.到处都是JAVA培训 ...

  8. JPA原理理解

    从前面一篇<JPA使用入门>了解了JPA的简单使用.要想继续深入的使用JPA,可能了解一点原理对于学习JPA会比较有益处. 这里从JPA的功能来简单阐述JPA的原理. 从<初步了解J ...

  9. Object.notifyAll()

    void java.lang.Object.notifyAll() Causes all threads which are waiting on this object's monitor (by ...

  10. 《C++primer》v5 第8章 IO库 读书笔记 习题答案

    8.1.8.2 这一章不咋会啊.. istream &read(istream &is) { int a; auto old_state=is.rdstate(); is.clear( ...