pessek/hypedropzone

Elgg 的拖放文件上传

安装: 3

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:elgg-plugin

4.0 2021-10-14 02:56 UTC

This package is auto-updated.

Last update: 2024-09-14 09:42:51 UTC


README

Elgg 4.0

Elgg 的拖放文件上传

功能

  • 跨浏览器支持拖放文件上传
  • 易于集成到现有表单中
  • 支持大文件的分块上传

Dropzone

开发者注意事项

添加拖放文件输入和处理上传

要将拖放输入添加到您的表单中,请添加以下内容

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

致谢 / 信用