使用驻留在远程服务器上的php脚本将文件从本地机器传输到远程服务器 [英] Transfer files from local machine to remote server with the php script residing on remote server

查看:118
本文介绍了使用驻留在远程服务器上的php脚本将文件从本地机器传输到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果php脚本(比如使用ftp函数)驻留在远程服务器上,是否有可能将文件从本地机器传输到远程服务器?我听说可能需要将本地计算机设置为FTP服务器,本地计算机应具有静态IP地址。



我正在寻找关于如何设置本地机器为ftp服务器?或者是否有任何其他方式使用php而不是表单文件上传($ _ FILES)的东西?



希望得到任何帮助。

解决方案

FTP可以工作,但是:


  • 如果服务器和客户端位于同一网络中,则可以使用网络共享。按照这条路线,你可以使用PHP提供的普通文件系统函数( docs ) 。只需使用网络名称和共享路径,将斜线翻转即可转发:// servername / path / to / share这是一个关于设置网络共享的教程,假设Windows是客户端操作系统。

  • 如果网络共享是不可能的,你可以设置一个本地FTP服务器。 这是一篇关于如何设置Lifehacker的文章这个,假设你有一个Windows操作系统。有类似的Mac和* nix的教程,有很多你不得不试试不要在Google上找到它们。 :)还有很多其他路由可以设置FTP服务器,使用哪个服务器并不那么重要,只要确保不让自己远离互联网。设置本地FTP服务器后,使用 PHP的FTP功能从服务器到您的本地机器。




如果可以的话,它确实是使用网络共享的更好途径,如果服务器不在您的本地网络中,那么这不是一个选项。


Is it possible to transfer a file from local machine to a remote server if the php script (say using ftp functions ) resides on a remote server?. I heard it might take to set up the local machine as a FTP server and the local machine should have a static IP address.

I am looking for directions as to how to set up the local machine to be a ftp server?., or is there any other way with php other than the form file upload($_FILES) thing ?.

Would appreciate any help. Thanks!.

解决方案

FTP will work, but:

  • If the server and the client are on the same network, you can use a network share. Going this route, you can use the normal filesystem functions available in PHP (docs). Just use the network name and share path, flip the slashes to forward: "//servername/path/to/share" Here is a tutorial on setting up a network share, assuming Windows is the client OS.

  • If network share is out of the question, you can set up a local FTP server. Here is a Lifehacker article on how to set this up, assuming you have a Windows OS. There are similar tutorials for Mac and *nix, there are so many you'd have to try NOT to find them on Google. :) There are many other routes to set up the FTP server, it isn't that important which server you use, just make sure you aren't leaving yourself wide open to the internet. After you set up the local FTP server, use PHP's FTP functions to connect from the server to your local machine.

It really is a better route to use the network share if you can, but of course that isn't an option if the server is not in your local network.

这篇关于使用驻留在远程服务器上的php脚本将文件从本地机器传输到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆