PHP 媒体上传库

发布于 2024-11-17 06:16:57 字数 1357 浏览 0 评论 0原文

我目前正在寻找一个可以管理多种类型文件的 PHP 媒体上传库。无论是单个库还是不同库的组合都可以同样有效。

我可以编写一些简单的上传代码来检查文件类型,并结合一些简单的安全措施,但我宁愿将其留给更有资格的其他人。


我在这样的库中寻找的功能:

  • 检查文件类型。我希望库有一个可以上传的文件类型的白名单,并且可以能够检查上传的文件是否确实在该白名单中。检查过程要做的不仅仅是检查文件扩展名。 示例:仅允许上传 .jpg、.png、.mp3、.avi。

  • 非常全面的设置页面/部分可理解和可编辑的代码。我希望能够塑造以适应我的网站的结构,而不是相反。

  • 安全检查。我希望有一个安全检查系统,以确保文件不会对我的网站构成可能的安全威胁。

  • 免费。我不想购买库。


到目前为止我找到的工具:

由于普遍需要文件上传代码,因此有大量的上传库,例如:

问题是,有太多的库、框架和类,很难选择一个(或多个组合使用)并知道它会可靠且运行良好。


所以,如果我能得到一些关于您认为最好的 PHP 文件上传库或包含我正在寻找的功能的库的建议,那就太棒了!

非常感谢!

I'm currently in the process of searching for a media upload library for PHP that can manage multiple types of files. Either a single library or a combination of different ones would work equally well.

I could write some simple upload code that checks what type of file, and incorporate some simple security measures, but I'd much rather leave it up to someone else more qualified.

Features I'm looking for in such a library:

  • Checking for file type. I would like the library to have a whitelist of types of files that can be uploaded, and be to able to check if the file uploaded is indeed on that whitelist. The checking process would have to do more than just check the file extension. Example: Only uploading .jpg, .png, .mp3, .avi is allowed.

  • Either a very comprehensive settings page/section or understandable and editable code. I'd like to be able to mold the library to fit the structure of my site, not the other way around.

  • Security checks. I would like there to be a system of security checks to make sure that files are not a possible security threat to my website.

  • Free. I'd rather not buy a library.

Tools I've Found So Far:

Due to the universal need for file upload code, there are tons of upload libraries out there, such as:

  • class.upload.php -- Manages the uploading, saving, and resizing of images.

  • Pear PHP's HTTP_Upload -- Manages files submitted via HTTP forms.

  • Easy PHP Upload -- Validates and manages file upload via Web forms

  • EasyUp -- Simply manages file upload.

The problem is, there's just so many libraries, frameworks, and classes out there that it's hard to choose one (or multiple to work in combination) and know that it's going to be reliable and work well.

So, it would be amazing if I could get some recommendations on what in your opinion the best file upload library or libraries are for PHP that contain the features I'm looking for!

Thanks a ton!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世俗缘 2024-11-24 06:16:57

嗯,这取决于您想要上传的内容。仅仅是图像吗?文本文件?视频?

无论如何,实际上并不需要库,因为 PHP 具有非常强大的内置上传功能。

页面展示了如何制作基本表单和实现一些基本安全性的一个很好的示例检查,包括检查文件扩展名。 PHP 本身就非常安全,但您必须自己决定接受哪些文件扩展名。一般来说,最好具体选择您将接受的文件,而不是仅限制一些高风险文件。例如,除非需要它们并且您想要支持它们,否则请避免支持存档(例如 7z、bz2 或 zip)或可执行文件。

另外,如果您想对新上传的文件进行非常基本的病毒扫描,您可以使用类似于 this 的方法一个

您希望能够将您的网站融合到所需的库中吗?使用 PHP 可以让您比任何方法都做得更好,而且相对简单。

Well, it depends on just what you want uploaded. Is it just images? Text files? Videos?

At any rate, a library wouldn't actually be needed because PHP has a very powerful built in upload function.

This page here shows a good example of how to make a basic form and implementing some basic security checks, including checking the file extension. PHP is very secure as it is, though you'll have to decide for yourself what file extensions you will accept. Generally, it's best to choose specifically what you will accept, rather than limiting out a few high risk files only. For example, unless they're needed and you want to support them, avoid supporting archives (such as 7z, bz2, or zip) or executables.

As well, if you want to put a very basic virus scan into the newly uploaded file, you can use a method similar to this one.

You want to be able to meld your site around the desired library? Using PHP lets you do that better than anything, and it's relatively simple to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文