ThinkCMF-smeta扩展字段
ThinkCMF - 添加文章功能 没有上传文件功能,为了扩展这一功能,在页面加入如下代码:
<tr> <td> <div style="text-align: center;"> <input type="hidden" name="smeta[thumb]" id="thumb" value=""> <a href="javascript:upload_one_image('图片上传','#thumb');"> <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="thumb-preview" width="135" style="cursor: hand" /> </a> <input type="button" class="btn btn-small" onclick="$('#thumb-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#thumb').val('');return false;" value="取消图片"> </div> </td> </tr> <tr> <td> <div style="text-align: center;"> <input type="hidden" name="smeta[file]" id="file" value=""> <a href="javascript:upload_one('文件上传','#file','file');"> <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="file-preview" width="135" style="cursor: hand" /> </a> <input type="button" class="btn btn-small" onclick="$('#file-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#file').val('');return false;" value="取消文件"> </div> </td> </tr>
关键方法: upload_one('文件上传','#file','file');
关键元素:<input type="hidden" name="smeta[file]" id="file" value="">
关键字段:smeta - post的扩展字段,保存相关扩展属性,如缩略图,格式为json。