简体   繁体   English

PHP媒体上传库

[英]PHP Media Upload Library

I'm currently in the process of searching for a media upload library for PHP that can manage multiple types of files. 我目前正在搜索可以管理多种类型文件的PHP媒体上传库。 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. 示例:仅允许上传.jpg,.png,.mp3,.avi。

  • 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: 由于对文件上传代码的普遍需求,有大量的上传库,例如:

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! 所以 ,如果我能得到一些关于你认为最好的文件上传库或PHP库包含我正在寻找的功能的建议,那将是一件非常棒的事情!

Thanks a ton! 万分感谢!

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. 无论如何,实际上并不需要库,因为PHP具有非常强大的内置上传功能。

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. PHP虽然很安全,但你必须自己决定接受哪些文件扩展名。 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. 例如,除非需要它们并且您想要支持它们,否则请避免支持存档(例如7z,bz2或zip)或可执行文件。

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. 使用PHP可以让你比任何东西做得更好,而且做起来相对简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM