HTML页面
<div class="form-group">
<label for="picurl" class="col-sm-2 control-label">标题图</label>
<div class="col-sm-8">
<div id="queue"></div>
<div>
<input id="file_upload" name="file_upload" type="file" multiple="false">
</div>
<div id="img" style="padding: 5px;">
</div>
<input type="hidden" id="picurl" name="picurl" value="" >
</div>
</div>
js页面
$('#file_upload').uploadifive({
'auto': true,
'multi': false,
'width': '100%',
'height': '35',
'buttonText': '请选择图片',
'fileType': 'image/jpg,image/jpeg,image/png',
'fileSizeLimit': 1024,
'queueSizeLimit': 1,
'formData': {},
'queueID': 'queue',
'uploadScript': '${base}/open/file/upload/image',
'onUploadComplete': function (file, data) {
data = JSON.parse(data);
if (data.code == 0) {
Toast.success(data.msg);
$("#img").html("<img src='" + data.data + "' style='width:150px;height:95px;'>");
$("#picurl").val(data.data);
} else {
clearFile();
Toast.error(data.msg);
}
},
'onDrop': function (file, fileDropCount) {
clearFile();
},
'onClearQueue': function (queue) {
clearFile();
},
'onCancel': function () {
clearFile();
}
});