uploadily 上传图片功能
<input type="file" id="avatar" class="webuploader-element-invisible" multiple="multiple" accept="image/*">
</p>
<input type="hidden" name="avatar_id" id="avatar_id" value="{$teacher.avatar_id}" placeholder="讲师照片"/>
<div class="upload-img-box1" style="margin-top: 20px;width: 250px">
<div class="upload-pre-item"><img src="{$teacher.avatar_id|get_cover='path'}"></div>
</div>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<script>
$("#avatar").uploadify({
"height": 30,
"swf": "__STATIC__/uploadify/uploadify.swf",
"fileObjName": "download",
"buttonText": "{:L('上传头像')}",
"buttonClass": "uploadcover",
"uploader": "{:U('Core/File/uploadPicture',array('session_id'=>session_id()))}",
"width": 250,
'removeTimeout': 1,
'fileTypeExts': '*.jpg; *.png; *.gif;',
"onUploadSuccess": uploadPicturecover,
'overrideEvents': ['onUploadProgress', 'onUploadComplete', 'onUploadStart', 'onSelect'],
'onFallback': function () {
alert("{:L('_FLASH_NOT_DETECTED_')}");
}, 'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
$("#avatar_id").parent().find('.upload-img-box1').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
}, 'onUploadComplete': function (file) {
alert('The file ' + file.name + ' finished processing.');
}, 'onUploadStart': function (file) {
alert('Starting to upload ' + file.name);
}, 'onQueueComplete': function (queueData) {
alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
}
});
function uploadPicturecover(file, data) {
alert('uploadPicturecover');
var data = $.parseJSON(data);
var src = '';
if (data.status) {
$("#avatar_id").val(data.id);
src = data.url || data.path
$('.upload-img-box1').html(
'<div class="upload-pre-item"><img src="' + src + '"/></div>'
);
} else {
toast.error("{:L('_ERROR_FAIL_UPLOAD_COVER_')}","{:L('_PROMPT_')}");
}
}
</script>
本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:admin@ptpc120.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。
Please Sign in After a review