我正在使用数据表中的标准上传功能。图像正确显示缩略图。如何获取上传的PDF以显示缩略图?目前,它仅显示一个小的损坏的文件图标。
从HTML:
{ "className": "dt-right", data: "image",
render: function ( file_id ) {
return file_id ?
'<img src="'+editor.file( 'files', file_id ).web_path+'" class="img-circle" width="40" height="40"/>' :
null;
},
defaultContent: "No image",
title: "image"
}
从PHP:
Field::inst( 'image' )
->setFormatter( 'Format::ifEmpty', null )
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
->db( 'files', 'id', array(
'filename' => Upload::DB_FILE_NAME,
'filesize' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
->validator( function ( $file ) {
return$file['size'] >= 2000000 ?
"Files must be smaller than 2M" :
null;
} )
->allowedExtensions( array( 'png', 'jpg', 'gif', 'pdf' ), "Please upload an image" )
)