**H5图片上传插件,H5文件上传插件** 搜索大量资料,没有符合自己的需求的上传插件,于是乎自己捣鼓出 了一个,非常好用,功能随心设置;话不多说,直接上 老版本已经下架,请下载新版本 [下载地址](https://github.com/wycto/jquery) github最新版下载:**请先购买去“H5文件上传插件”章节。** 文档说明:**请先购买去“H5文件上传插件”章节。** 使用方法: 1.在文档底部任何位置放置 如下标签 ~~~ <input id="avatar" type="file" accept="image/*" multiple="multiple" style="display:none"/> ~~~ 2.设置点击上传按钮 ~~~ <div id="your_img"> <img src="images/avatar.jpg" /> </div> ~~~ 3.上传js代码 ~~~ $('#your_img span').click(function(){ $("#avatar").wyUpload({ method:0, allowType:['jpg', 'jpeg', 'png', 'gif'], allowSize:500, success:function(img){ $("#your_img>img").attr("src",img); }, error:function(message){ $.messager.alert('温馨提示',message,'warning'); } }); $("#avatar").click(); }); ~~~ 该方法为base64上传方式, 4.php base64转换代码 ~~~ /** * base64图片上传 * * @param string $img * base64字符串 * @return 图片保存路劲 */ function uploadFile($img = "", $fileext = 'jpg') { if ($img != "") { $i = stripos($img, "base64,"); $base = substr($img, $i + 7); $img = base64_decode($base); if ($fileext == 'jpg' || $fileext == 'png' || $fileext == 'gif' || $fileext == 'jpeg' || $fileext == 'bmp') { $dir = './attached/image/' . date("Ymd", time()); } else { $dir = './attached/file/' . date("Ymd", time()); } if (!is_dir($dir)) mkdir($dir); $url = $dir . '/' . time() . "." . $fileext; $a = file_put_contents($url, $img); $url = substr($url, 1); return $url; } } ~~~ <h4 style="color:green;font-weight:700">有不懂的,请留言</h4>