PHP+jQuery+html5实现图片选取裁剪上传(兼容手机上传)

PHP+jQuery+html5实现图片选取裁剪上传(兼容手机上传)

在网上找到了图片上传插件jquery.min.js,但没有上传功能,自己花了10分钟给加上去了哈,有bug留言,一般当天改完上传。

淘建站为您提供更多_表单代码_拖拽_上传_html5,在此特别感谢您对我们的支持与厚爱!

查看演示

演示不了,点击反馈

加入收藏

下载 422 次

打赏作者

觉得不错,可打赏下作者

下载资源

免费共享

特别说明:本站资源来自网友发布分享,仅供学习与参考,请勿用于商业用途,若有侵权请联系删除(272966172@qq.com)。

HTML

首先我们放置一个上传按钮及相关预览信息等。

<form id="upload_form" enctype="multipart/form-data" method="post" action="upload.php" onsubmit="return checkForm()"> 
   <!-- hidden crop params --> 
   <input type="hidden" id="x1" name="x1" autocomplete="off" /> 
   <input type="hidden" id="y1" name="y1" autocomplete="off" /> 
   <input type="hidden" id="x2" name="x2" autocomplete="off" /> 
   <input type="hidden" id="y2" name="y2" autocomplete="off" /> 
   <input type="file" name="image_file" id="image_file" onchange="fileSelectHandler()" /> 
   <div class="error">
    注意:上传前,先截图
   </div> 
   <div class="step2"> 
    <img id="preview" /> 
    <div class="info"> 
     <ul> 
      <li><label>文件大小</label> <input type="text" id="filesize" name="filesize" class="input" autocomplete="off" /></li> 
      <li><label>类型</label> <input type="text" id="filetype" name="filetype" class="input" autocomplete="off" /></li> 
      <li><label>图像尺寸</label> <input type="text" id="filedim" name="filedim" class="input" autocomplete="off" /></li> 
      <li><label>宽度</label> <input type="text" id="w" name="w" class="input" autocomplete="off" /></li> 
      <li><label>高度</label> <input type="text" id="h" name="h" class="input" autocomplete="off" /></li> 
     </ul> 
    </div> 
    <input type="submit" value="上传" class="btn" /> 
   </div> 
</form>

接着我们引用jQuery库和Jcrop插件。

<link href="css/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script> 
<script src="js/jquery.Jcrop.min.js"></script>

jQuery

接着我们看下表单的检查:

function checkForm() {
    if (parseInt($('#w').val())) //若是没有截屏
        return true;
    $('.error').html('请先选择图片,并且截图').show();
    return false;
}

上传文件条件设置:

var rFilter = /^(image\/jpeg|image\/png|image\/jpg)$/i;
if (!rFilter.test(oFile.type)) {
    $('.error').html('请选择jpg、jpeg或png格式的图片').show();
    return;
}

// check for file size
if (oFile.size > 1000 * 1024) {
    $('.error').html('请上传小于1M的图片').show();
    return;
}

这是一个单图片上传,并且兼容手机图片上传。相关多图片上传:PHP+jQuery+Ajax多图片上传, flash头像上传插件

声明:本资料由淘建站会员提供,如转载注明来源,资料来源淘建站免费素材库:https://www.taojz.cn/texiao/71.html
PHP+jQuery+html5实现图片选取裁剪上传(兼容手机上传) 希望对你有帮助,感谢您的支持!
  • html5网格图片瀑布流布局加载动画特效

    html5网格图片瀑布流布局加载动画特效

  • jQuery+css3+html5响应式瀑布流插件

    jQuery+css3+html5响应式瀑布流插件

  • html5瀑布流图片点击弹出大图片信息代码

    html5瀑布流图片点击弹出大图片信息代码

  • html5手机瀑布流图片加载效果

    html5手机瀑布流图片加载效果

  • html5 css3打造自适应屏幕自动加载瀑布流

    html5 css3打造自适应屏幕自动加载瀑布流

  • html5 CSS3模拟视差图片跳动瀑布流布局效果

    html5 CSS3模拟视差图片跳动瀑布流布局效果

  • win8 Metro风格界面的html5瀑布流布局无限加载代码

    win8 Metro风格界面的html5瀑布流布局无限加载代码

  • html5瀑布流图片鼠标悬停svg变形动画显示标题图片

    html5瀑布流图片鼠标悬停svg变形动画显示标题图片

  • html5 modernizr图片瀑布流布局点击弹出图片滑动预览

    html5 modernizr图片瀑布流布局点击弹出图片滑动预览

  • 黑色炫酷的html5飘雪星空引导页模板

    黑色炫酷的html5飘雪星空引导页模板

  • html5 css3适用于手机端网站入口引导页模板

    html5 css3适用于手机端网站入口引导页模板

  • html5动漫风格的引导页加载动画特效

    html5动漫风格的引导页加载动画特效

  • 留言(0)
    头像
     阿里云限量代金券,戳我领取
    1 2