标签:odi hang val 覆盖 size gty on() this ict
//定义api
$("#photo").change(function(){
//获取图片
api.getPicture({
sourceType: ‘library‘,
encodingType: ‘png‘,
mediaValue: ‘pic‘,
destinationType: ‘url‘,
allowEdit: true,
//quality: 50,
//targetWidth:100,
//targetHeight:100,
saveToPhotoAlbum: false
}, function(ret, err){
if (ret) {
api.ajax({
timeout : 100,
method : ‘post‘,
url : ‘http://192.168.0.35/jsz/wx.php/fbtime/add‘,
data : {
files:{upfile : ret.data},
},
dataType : ‘json‘,
}, function(ret, err) {
//alert(ret.data.tp);
api.hideProgress();
var tp = {};
tp=ret.data.tp
$("#tpyc").html(tp);
fabu.tp = ret //JSON.stringify;
});
} else {
api.alert({msg:err.msg});
};
});
});//上传图片结束
//服务器接受(tp)
import(‘ORG.Net.UploadFile‘);
$upload = new UploadFile(); // 实例化上传类
// $upload->thumb = true;
$upload->thumbMaxWidth = ‘50,150‘;
$upload->thumbMaxHeight = ‘50,120‘; // 设置附件上传大小
$upload->maxSize = ‘1000000‘; // 默认为-1,不限制上传大小
$upload->uploadReplace = true; // 如果存在同名文件是否进行覆盖
$upload->allowExts = array(
‘jpg‘,
‘png‘,
‘jpeg‘,
‘JPG‘,
‘PNG‘
); // 设置附件上传类型
$upload->allowTypes = array(
‘image/png‘,
‘image/jpg‘,
‘image/jpeg‘
);
$upload->savePath = ‘./Uploads/gong/picture/‘; // 设置附件上传目录
$upload->upload();
// if(!$upload->upload()) {// 上传错误提示错误信息
// $this->error($upload->getErrorMsg());
// }else{// 上传成功 获取上传文件信息
$photo = $upload->getUploadFileInfo();
// }
// 保存表单数据 包括附件数据
// $chanpin = M("chanpin"); // 实例化User对象
// $data[‘picture‘] = $photo[0][‘savename‘]; // 保存上传的照片根据需要自行组装
// $chanpin->where("id=$id")->save($data); // 写入用户数据到数据库
// $this->success(‘数据保存成功!‘);
$tp = $photo[0][‘savename‘]; //返回文件名给JS作回调用
$fh[‘tp‘] = $tp;
$this->ajaxReturn($fh);
。只是大概思路!
标签:odi hang val 覆盖 size gty on() this ict
原文地址:http://www.cnblogs.com/wxt01/p/6413277.html