<!--引入必要的dom-->
<div style="text-align: center" style="backgroud:url(http://weixin.hunankeji.com/static/apps/lovemomo/img/online.png) no-repeat center">
<input type="file" id="uploadphoto" name="file" value="上传" accept="image/*" capture="camera" style="opacity: 0;height: 320px;width:320px;border: 0;"/>
</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js" ></script>
<script type="text/javascript" src="./localresizeimg/LocalResizeIMG.js"></script>
<script type="text/javascript" src="./localresizeimg/patch/mobileBUGFix.mini.js"></script>
<script>
$('#uploadphoto').localResizeIMG({
width: 400,
quality: 1,
success: function (result) {
var submitData={
data:result.clearBase64,
};
$('.loading').show();
$("#prevImg").attr("src",result.base64);
$.ajax({
type: "POST",
url: "{:U('Album/uploadb64',array('id'=>$appid))}",
data: submitData,
dataType:"json",
success: function(data){
$("#prevImg").attr("src", data.url);
$('#imgurl').val(data.url);
$('.loading').hide();
},
complete :function(XMLHttpRequest, textStatus){
$('.loading').hide();
},
error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败
alert("额,出错了,请上报给管理员吧");
$('.loading').hide();
}
});
}
});
</script>点击这里下载 localresizeimg,如果不能下载,请访问http://www.imwinlion.com/archives/158 function base64toimage($strBase64, $dstPath ) {
$ifp = fopen( $dstPath, "wb" );
fwrite( $ifp, base64_decode( $strBase64) );
fclose( $ifp );
return( $dstPath );
}其中$strba// If ALLOW_EXTERNAL is true and ALLOW_ALL_EXTERNAL_SITES is false, then external images will only be fetched from these domains and their subdomains.
if(! isset($ALLOWED_SITES)){
$ALLOWED_SITES = array (‘youhost.com’,’imwinlion.com’);
} server {
listen 80;
server_name img.imwinlion.com;
index index.html index.htm index.php;
root /alidata/mnt/imwinlion;
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ (.*)\.(gif|jpg|jpeg|png|PNG|JPG|JPEG)\!(\d+)x(\d+)$
{
try_files 1ドル.2ドル /empty last;
image_filter_interlace on;
image_filter_jpeg_quality 90;
image_filter resize 3ドル 4ドル;
image_filter_buffer 3M;
}
location ~ .*\.(gif|jpg|JPG|PNG|GIF|BMP|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /dev/null;
}本文章涉及到的相关代码会在微信公众帐号itchuangyebuluo,陆续放出,敬请关注。ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。