管理后台游戏编辑上传图片限制大小

master
zhengyongxing 5 years ago
parent f009243399
commit dce35b6ff1

@ -200,6 +200,14 @@ class FileController extends AdminController
/* 调用文件上传组件上传文件 */ /* 调用文件上传组件上传文件 */
$Picture = D('Picture'); $Picture = D('Picture');
$pic_driver = C('PICTURE_UPLOAD_DRIVER'); $pic_driver = C('PICTURE_UPLOAD_DRIVER');
if (I('icon')) {
if ($_FILES['file']['size'] > 51200) {
$return = array('status' => 1001, 'info' => '图片大小不得超过50k', 'data' => '');
$this->ajaxReturn($return);
}
}
$info = $Picture->upload( $info = $Picture->upload(
$_FILES, $_FILES,
C('PICTURE_UPLOAD'), C('PICTURE_UPLOAD'),

@ -251,7 +251,7 @@
</div> </div>
</div> </div>
</span> </span>
<span class="notice-text">尺寸不得小于512*512px圆角半径113px不强制要求可直接提供512*512方图</span> <span class="notice-text">尺寸不得小于125*125px大小不得超过50K</span>
</td> </td>
</tr> </tr>
<tr class="picbox"> <tr class="picbox">
@ -1679,6 +1679,7 @@
</script> </script>
<script> <script>
var iconInfo = {userId:"kazaff", md5:"",icon:1}; //用户会话信息
var uploaderImgIcon = WebUploader.create({ var uploaderImgIcon = WebUploader.create({
// 选完文件后,是否自动上传。 // 选完文件后,是否自动上传。
auto: true, auto: true,
@ -1707,7 +1708,7 @@
thumb:true, thumb:true,
compress:false, compress:false,
prepareNextFile: true, prepareNextFile: true,
formData: function(){return $.extend(true, {}, userInfo);}, formData: function(){return $.extend(true, {}, iconInfo);},
chunked:false, chunked:false,
duplicate: true duplicate: true
}); });
@ -1789,23 +1790,29 @@
imgListIconData.push(Number(response.id)); imgListIconData.push(Number(response.id));
setIconVal(); setIconVal();
console.log(response) console.log(response)
$( '#'+file.id ).find('p.state').text('已上传').fadeOut(800); if (response.status==1001) {
//alert(JSON.stringify(response)); alert('图片大小不得超过50k');
$('#'+file.id).find('h4.info').append('<a href="javascript:;" class="jsdelzip table_click" style="float:none;display:inline-block;margin-left:10px;">删除</a>'); $('#icon_thelist').children().last().remove();
$('#'+file.id).find('.jsdelzip').on('click',function() { } else {
uploaderImgIcon.removeFile( file.id ); $( '#'+file.id ).find('p.state').text('已上传').fadeOut(800);
$('#'+file.id).remove(); //alert(JSON.stringify(response));
$('#'+file.id).find('h4.info').append('<a href="javascript:;" class="jsdelzip table_click" style="float:none;display:inline-block;margin-left:10px;">删除</a>');
$('#'+file.id).find('.jsdelzip').on('click',function() {
uploaderImgIcon.removeFile( file.id );
$('#'+file.id).remove();
$.each(imgListIconData,function(index, item) {
if (response.id == item) {
imgListIconData.splice(index,1);
return false;
}
});
setIconVal();
$.each(imgListIconData,function(index, item) { return false;
if (response.id == item) {
imgListIconData.splice(index,1);
return false;
}
}); });
setIconVal(); }
return false;
});
}); });
function setIconVal() function setIconVal()

Loading…
Cancel
Save