朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

Flarum FoF 文件上传器

[scode]原文:https://discuss.flarum.org/d/4154
作者:luceos
翻译:Golden[/scode]

Upload by FriendsOfflarum

license packagist downloads

一个为您的论坛(flarum)智能处理文件上传的扩展程序。您需要安装 PHP 扩展 exif 后方可上传图片。

功能

  • 图片上传

    • 自动水印。
    • 自动缩放
  • 使用 MIME 限定文件上传类型。
  • 本地、第三方存储服务支持(imgur、AWS S3、七牛云)。
  • 支持拖拽、粘贴上传。
  • 支持批量上传文件(按钮、拖拽上传均支持)。
  • 易扩展性,本扩展高度依赖于事件。

安装

通过巴扎市场或 composer 手动安装:

composer require fof/upload

升级

composer require fof/upload
php flarum migrate
php flarum cache:clear

从 Flagrow 版本升级

本扩展是旧版 Flagrow Upload 的替代。

要从旧扩展升级到当前版本:

  • 备份数据库!您应该备份好数据库以及所有上传的文件。
  • 确保您当前是 Flagrow Upload 的最新版本,请运行:

    composer require flagrow/upload
    composer show flagrow/upload # You should see "versions: * 0.7.1" on the 4th line of output
    php flarum migrate
  • 在后台禁用上传插件。
  • 运行:

    composer require fof/upload

Composer 应该会输出

flagrow/upload

已经被自动删除的信息。

  • 在后台开启新版上传插件。
  • 您此前旧版本的设置、上传元数据将会自动合并到 FoF Upload 旗下。
  • 帖子中的文件插入代码会自动更新为 FoF 头,这意味着您不需要删除他们。

设置

启用插件,新选项卡将会出现在左侧菜单栏。此设置页面可以让您进一步配置扩展程序。

请确保同时在权限页面上配置上传权限。

文件模板

文件模板详情请查看插件设置里的说明。这里注意一下,模板是由处理优先级的,同一个 MIME 类型文件,最上层的文件模板会覆盖掉下层设置的文件模板。

Mimetype 正则表达式

正则表达式使您拥有很大的自由度,但是它们也很难理解。这里有一些提示,您随时可以在 Flarum 官方论坛上寻求帮助。

  • 如果要允许所有常规文件类型,包括视频、音乐、压缩文件和图像,请使用以下命令:

    (video\/(3gpp|mp4|mpeg|quicktime|webm))|(audio\/(aiff|midi|mpeg|mp4))|(image\/(gif|jpeg|png))|(application\/(x-(7z|rar|zip)-compressed|zip|arj|x-(bzip2|gzip|lha|stuffit|tar)|pdf))
  • 如果您需要允许上传所有图片文件,请使用通配符:

    ^image\/.*

MIME 类型由 主要类型 + 次要类型 组成。主类型可以是

image
video
application
png
pdf
/
\/

有关 MIME 类型,可以查看

MDN 文档

另外请注意,您添加的规则是有优先级的,最先添加的规则,优先级最高:

img

常见问题

  • AWS S3 配置:请阅读 AWS S3 配置页面
  • 启用插件、上传图片报错:请检查是否安装了 PHP 的扩展 exif

链接

FriendsOfflarum 制作扩展

赞(1) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » Flarum FoF 文件上传器

评论 27

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #30

    Everyone loves what you guys tend to be up too.
    This sort of clever work and reporting! Keep up the good works
    guys I’ve added you guys to our blogroll.

  2. #29

    Heya i am for the primary time here. I came across this board and
    I to find It truly helpful & it helped me out a lot.

    I hope to present one thing again and aid others such as you aided me.

  3. #28

    Pretty section of content. I just stumbled upon your blog and in accession capital to assert that I
    acquire in fact enjoyed account your blog posts.

    Any way I will be subscribing to your augment and even I achievement you access consistently fast.

  4. #27

    I really like what you guys tend to be up too. This type of
    clever work and coverage! Keep up the wonderful works
    guys I’ve you guys to my blogroll.

  5. #26

    It’s perfect time to make a few plans for the longer term
    and it is time to be happy. I’ve read this post and
    if I could I wish to counsel you few attention-grabbing things or
    advice. Perhaps you could write next articles referring to this
    article. I want to learn even more things approximately it!

    tinyurl.com1周前 (08-10)回复
  6. #25

    certainly like your web-site but you need to
    test the spelling on several of your posts. Many of
    them are rife with spelling issues and I in finding
    it very bothersome to inform the reality on the other hand I’ll surely come back again.

  7. #24

    Excellent post. I used to be checking constantly this weblog and
    I’m inspired! Very useful info specially the final phase 🙂 I take care of such info a lot.
    I used to be seeking this certain information for a
    very lengthy time. Thanks and good luck.

  8. #23

    What’s up, I read your blogs daily. Your writing style is witty, keep doing what you’re doing!

  9. #22

    Hi there friends, its fantastic piece of writing concerning teachingand entirely defined, keep it up all
    the time.

  10. #21

    Simply desire to say your article is as astonishing.
    The clarity in your post is just great and i could assume
    you are an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post.

    Thanks a million and please keep up the enjoyable work.

    tinyurl.com1个月前 (07-07)回复
  11. #20

    Thank you for great content. Hello Administ .

    Cami Halısı2个月前 (06-15)回复
  12. #19

    Hi there it’s me, I am also visiting this web site regularly, this web site is genuinely pleasant and
    the people are really sharing good thoughts.

    tinyurl.com2个月前 (06-12)回复