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. 在ubuntu中安装psutil

    环境:ubuntu 16.04 LTS + python 2.7/3.5共存 + psutil 4.3.0 1.sudo apt-get install python3-dev # 先把python3 ...

  2. [并查集] POJ 1182 食物链

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 66294   Accepted: 19539 Description ...

  3. 利用Cayley-Hamilton theorem 优化矩阵线性递推

    平时有关线性递推的题,很多都可以利用矩阵乘法来解决. 时间复杂度一般是O(K3logn)因此对矩阵的规模限制比较大. 下面介绍一种利用利用Cayley-Hamilton theorem加速矩阵乘法的方 ...

  4. 安卓自动化测试:Android studio 自带的 Record Espresso Test || [ Appium & (Android studio || Python|| Eclipse ) ]

    1.Android studio 自带的 Record Espresso Test  https://developer.android.com/studio/test/espresso-test-r ...

  5. Redis 3.0.0 集群部署

    简述: 1.0.1:redis cluster的现状 目前redis支持的cluster特性 1):节点自动发现 2):slave->master 选举,集群容错 3):Hot reshardi ...

  6. linux命令每日一练习 解压命令

    .tar 解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gun ...

  7. Tomcat Shell脚本(启动|关闭|重启|状态)

    #!/bin/bash # # chkconfig: - # description: Tomcat start/stop/status script #Location of JAVA_HOME ( ...

  8. 读IT小小鸟有感

           第一次阅读<我是一只IT小小鸟>是在老师的推荐下的,我是一名软工大一新生,那天在课堂上听到了这本书,由于是10年前的老书,要找到它非常不易,终于在网上看到一些部分电子档.   ...

  9. Python的平凡之路(14)

    一.什么是HTML HTML(Hyper Text Mark-up Language ) 即超文本标记语言,是 WWW 的描述语言,由 Tim Berners-lee提出.设计 HTML 语言的目的是 ...

  10. 区分苹果Safari浏览器

    区分苹果Safari浏览器 (function() { var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; (s = ua ...