日期:2014-05-17  浏览次数:20573 次

HTML5 拖拽上传图片实例

拖拽上传最重要的就是js部分的代码,它实现了70%的功能,另外30%仅仅是把图片信息提交到后台,然后做对应的处理,比如压缩啊,裁剪啊云云。所以先来看下js实现代码吧。

?
$().ready(function(){
????if($.browser.safari || $.browser.mozilla){
????????$('#dtb-msg1 .compatible').show();
????????$('#dtb-msg1 .notcompatible').hide();
????????$('#drop_zone_home').hover(function(){
????????????$(this).children('p').stop().animate({top:'0px'},200);
????????},function(){
????????????$(this).children('p').stop().animate({top:'-44px'},200);
????????});
????????//功能实现
????????$(document).on({
????????????dragleave:function(e){
????????????????e.preventDefault();
????????????????$('.dashboard_target_box').removeClass('over');
????????????},
????????????