简体   繁体   English

使用PHP和FTP上传大文件

[英]Upload big files with PHP and FTP

I need to write a script to upload big Files (~2GB+) to a server. 我需要编写一个脚本来将大文件(〜2GB以上)上传到服务器。 I don't think HTTP is the right way to do this so I want to use (S)FTP. 我认为HTTP不是执行此操作的正确方法,因此我想使用(S)FTP。 There are several tutorials about this (using cURL or ftp_connect) and I understand that i have to set several things in the php.ini. 有一些关于此的教程(使用cURL或ftp_connect),我了解我必须在php.ini中设置几件事。

But all this tutorials upload the file to a remote Server, what I want to do is upload it to the Server the script is running on, without having to upload the file to the Server over HTTP first. 但是所有这些教程都将文件上传到remote服务器,我要做的就是将文件上传到运行脚本的服务器,而不必先通过HTTP将文件上传到服务器。

Is this possible? 这可能吗? If so, how would I do that? 如果是这样,我该怎么做?

HTTP can be the right way to upload large files. HTTP 可能是上传大型文件的正确方法。 You can use resumable.js or similar library to split the file in "chunks" and then reassemble the file on the server. 您可以使用resumable.js或类似的库将文件拆分为“块”,然后在服务器上重新组装该文件。

If you decided not to go with HTTP and have shell access, I recommend you use rsync (with the --partial flag) which will do the heavy lifting for you. 如果您决定不使用HTTP并具有外壳程序访问权限,我建议您使用rsync (带有--partial标志),它将为您完成繁重的工作。

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

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