jquery插件fileupload图片上传(前端如何处理)
1.页面首先引入jquery,版本不要低于1.6
<script src="../js/jquery.min.js"></script>
2.其次页面引入对应的这个五个js,按顺序放置
<script src="../js/jquery.ui.widget.js"></script>
<script src="../js/jquery.iframe-transport.js"></script>
<script src="../js/jquery.fileupload.js"></script>
<script src="../js/jquery.fileupload-process.js"></script>
<script src="../js/jquery.fileupload-ui.js"></script>
3.html结构如下:
<div class="control-group"><label>上传头像:</label>
<div class="controls upload-bg"><!---->
<input class="upload" id="file" type="file" name="file">
<img src="" style="display:none;width:100%;height:100%" id="target" alt="[Jcrop Example]"/>
<input type="hidden" value="" id="url">
</div>
<p class="reupload">重新上传
<input class="imgEditor" id="uploadNext" type="file" name="file" value=""/>
</p>
</div>
这个样式是这样的:
4.css样式如下:如有些结构和样式不一致的,希望自己调整一下
/*上传图片*/
.control-group .upload {
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
} .control-group .upload-bg {
width: 240px;
height: 240px;
position: relative;
border: 1px solid #ccc;
background: url("../images/upload.png") center no-repeat;
margin-left: 200px;
margin-top: -25px;
}
.control-group .upload-bg:hover {
border: 1px dashed #0000FF;
transition: border 1s;
}
.control-group .upload-bg p, .imgEditor {
position: absolute;
bottom: 0;
display: none;
text-align: center;
width: 100%;
margin: 0;
background: #210606;
opacity: 0.6;
color: #ccc;
cursor: pointer;
}
.control-group .upload-bg:hover {
border: 1px dashed #0000FF;
transition: border 1s;
}
.fm .reupload{margin-bottom:0 !important;}
.control-group .upload-bg p, .imgEditor {
position: absolute;
bottom: 0;
display: none;
text-align: center;
width: 100%;
margin: 0;
background: #210606;
opacity: 0.6;
color: #ccc;
cursor: pointer;
}
.imgEditor {
opacity: 0;
z-index: 2;
left: 0;
height: 100% !important;
display: block;
}
.reupload{
margin-top:2px;
position: relative;
height: 24px !important;
width: 243px !important;
margin-left: 200px;
line-height: 24px;
background: #9999CC;
display: none;
}
5.上传的js部分:
function imgUpLoad(eleId) {
$('#' + eleId).fileupload({
autoUpload: true,//自动上传
url: "http://xxxxx.url",//ַ上传图片对应的地址
dataType: 'json',
done: function (e, data) {
var oimage = data, _this = $('#' + eleId);
if (eleId == 'file') {
_this.hide();
_this.siblings('img').attr('src', oimage.result.url).show();
$('.reupload').show();//第一次上传完成,显示重新上传
} else {//重新上传
_this.closest('.control-group').find('#target').attr('src', oimage.result.url);
}
}
})
}
6.最后上传完成之后是这样的(其实还有裁剪的功能,下一篇介绍)
jquery插件fileupload图片上传(前端如何处理)的更多相关文章
- JQuery插件:图片上传本地预览插件,改进案例一则。
/* *名称:图片上传本地预览插件 v1.1 *作者:周祥 *时间:2013年11月26日 *介绍:基于JQUERY扩展,图片上传预览插件 目前兼容浏览器(IE 谷歌 火狐) 不支持safari *插 ...
- Jquery插件-Html5图片上传并裁剪
/** * 图片裁剪 * @author yanglizhe * 2015/11/16 */ (function($){ /** * Drag */ var Drag={obj:null,init:f ...
- 【转】JQuery插件ajaxFileUpload 异步上传文件(PHP版)
前几天想在手机端做个异步上传图片的功能,平时用的比较多的JQuery图片上传插件是Uploadify这个插件,效果很不错,但是由于手机不支持flash,所以不得不再找一个文件上传插件来用了.后来发现a ...
- JQuery插件ajaxFileUpload 异步上传文件(PHP版)
太久没写博客了,真的是太忙了.善于总结,进步才会更快啊.不多说,直接进入主题. 前几天想在手机端做个异步上传图片的功能,平时用的比较多的JQuery图片上传插件是Uploadify这个插件,效果很不错 ...
- java多图片上传--前端实现预览--图片压缩 、图片缩放,区域裁剪,水印,旋转,保持比例。
java多图片上传--前端实现预览 前端代码: https://pan.baidu.com/s/1cqKbmjBSXOhFX4HR1XGkyQ 解压后: java后台: <!--文件上传--&g ...
- jQuery插件AjaxFileUpload文件上传实现Javascript多文件上传功能
Ajax file upload plugin是一个功能强大的文件上传jQuery插件,可自定义链接.或其它元素庖代传统的file表单上传结果,可实现Ajax动态提示文件上传 过程,同时支撑多文 ...
- Uploadify & jQuery.imgAreaSelect 插件实现图片上传裁剪
在网站中需要一个图片上传裁剪的功能,借鉴这篇文章 Ajax+PHP+jQuery图片截图上传 的指点,找到了jquery.imgAreaSelect这个不错插件,能对图片进行自定义区域选择并给出坐标, ...
- 网站开发常用jQuery插件总结(15)上传插件blueimp
在介绍这个插件之前,先吐槽一下.这个插件功能很强大.带有的功能有:上传(单个文件或批量文件),自动上传或点击按钮上传,上传前缩略图显示,判断文件格式,上传前的文件操作,上传时进度条显示等功能.如果你用 ...
- JQuery插件ajaxFileUpload 异步上传文件
一.先对ajaxFileUpload插件的语法参数进行讲解 原理:ajaxfileupload是通过监听iframe的onload方法来实现, 当从服务端处理完成后,就触发iframe的onload事 ...
随机推荐
- Java for LeetCode 122 Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- em、pt、px和百分比
浏览器默认的字体大小为100%=16px=12pt=1em px像素(Pixel):是固定大小的单元.相对长度单位.像素px是相对于显示器屏幕分辨率而言的.一个像素等于电脑屏幕上的一个点(是你屏幕分辨 ...
- hadoop —— MapReduce例子 (求平均值)
参考:http://eric-gcm.iteye.com/blog/1807468 math.txt: 张三 88 李四 99 王五 66 赵六 77 china.txt: 张三 78 李四 89 王 ...
- POJ3261 Milk Patterns —— 后缀数组 出现k次且可重叠的最长子串
题目链接:https://vjudge.net/problem/POJ-3261 Milk Patterns Time Limit: 5000MS Memory Limit: 65536K Tot ...
- PYTHON 爬虫笔记六:PyQuery库基础用法
知识点一:PyQuery库详解及其基本使用 初始化 字符串初始化 html = ''' <div> <ul> <li class="item-0"&g ...
- OpenCV——PS滤镜之 波浪效果 wave
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- [acm]HDOJ 2059 龟兔赛跑
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2059 起点和终点,共n+2个点,n+2个状态,简单DP即可. //11512698 2014-08- ...
- hdu3501Calculation 2——欧拉函数模板
题目: Problem Description Given a positive integer N, your task is to calculate the sum of the positiv ...
- SpringMVC之二:配置 Spring MVC
Servlet 3.0规范在2009年12月份就发布了,因此很有可能你会将应用部署到支持Servlet 3.0的Servlet容器之中,如tomcat7.0及以上.在Servlet 3 规范中,可以使 ...
- 如何使用Git命令将项目从github或者服务器上克隆下来
在本地新建一个文件夹,作为本地仓库,如“demo”.单击右键git Bush here,打开git,输入命令: cd /c/Users/Administrator/Desktop/demo 然后按回 ...

