pessek / hypedropzone
Elgg 的拖放文件上传
4.0
2021-10-14 02:56 UTC
Requires
- php: >=7.4
- composer/installers: ~1.0
- npm-asset/dropzone: <=5.4.0 || >5.5.0
This package is auto-updated.
Last update: 2024-09-14 09:42:51 UTC
README
Elgg 的拖放文件上传
功能
- 跨浏览器支持拖放文件上传
- 易于集成到现有表单中
- 支持大文件的分块上传
开发者注意事项
添加拖放文件输入和处理上传
要将拖放输入添加到您的表单中,请添加以下内容
echo elgg_view('input/dropzone', array( 'name' => 'upload_guids', 'accept' => "image/*", 'max' => 25, 'multiple' => true, 'container_guid' => $container_guid, // optional file container 'subtype' => $subtype, // subtype of the file entities to be created // see the view for more options ));
在您的操作中,您可以使用 get_input('upload_guids');
获取上传的文件
您还需要实现一个当浏览器不支持拖放时的回退解决方案。请参考 hypeJunction\DropzoneService
的示例。
初始化和重置 dropzone
您可以通过在包含表单上触发 jQuery 事件来实例化和清除 dropzone
$('.elgg-form').trigger('initialize'); // will instantiate dropzone inputs contained within the form $('.elgg-form').trigger('reset'); // will clear previews and hidden guid inputs
致谢 / 信用
- Dropzone.js 是 Matias Meno 编写的真正酷的库 http://www.dropzonejs.com/