将文件保存到远程域
我想在一台服务器上托管上传脚本,但将上传的文件存储到远程服务器。
目前我有一个脚本可以保存到我的服务器上的可写文件夹中。这工作正常,但是当我将其更改为绝对链接(即“http://www.somedomain.com/uploads/”而不是“/uploads/”)时,它说该文件夹不可写。该文件夹的权限是0777。我做错了什么吗?
最终我想将上传保存到远程服务器(即“http://www.someotherdomain.com/uploads/”)。有什么见解吗?我如何使用密码权限来做到这一点,以消除任何人将文件上传到此文件夹的可能性?
提前致谢!
I'd like to host an uploading script on one server but have it store the uploaded files to a remote server.
Currently I have a script that saves to a writable folder on my server. This works fine, but when I change it to the absolute link (ie. "http://www.somedomain.com/uploads/" instead of "/uploads/") it says the folder is not writable. The permissions on the folder are 0777. Am I doing something wrong?
Eventually I would like to save the uploads to a remote server (ie. "http://www.someotherdomain.com/uploads/"). Any insights? How could I do this with password permissions to eliminate the potential for anybody to upload files to this folder?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是一个选项:
将文件临时上传到您的服务器。上传到本地主机后,使用 curl 将文件上传到远程服务器。
为了保护密码,您可以使用访问令牌每 1 小时左右就会过期。将 access_token 作为变量传递给您的上传请求。远程服务器在接受上传之前验证access_token存在且未过期。
设置访问的用户名和密码。如果访问令牌不存在或已过期,请使用curl将用户名和密码发布到远程服务器,这将验证用户名和密码是否有效并返回新的access_token。
Following is an option:
Upload a file temporarily to your server. Once uploaded to localhost, use curl to upload the file to remote server.
For password protection you can use an access token which expires every 1 hour or so. Pass access_token as a variable with your upload request. Remote server verifies that access_token exists and has not expired before accepting the upload.
Set a username and password for the access. If access token does not exist or has expired use curl to post username and password to remote server, which will verify if username and password are valid and returns new access_token.
通过 ftp 尝试
http://php.net/manual/de/book.ftp.php
Try in via ftp
http://php.net/manual/de/book.ftp.php
我想我曾经遇到过这个问题。如果我对你的问题的理解没有错的话,我的问题是这样的。我在服务器A中创建upload.php并在服务器A中接收,假设该文件是receive.php(它正常工作)。然后我将接收文件(receive.php)上传到服务器B,并修改服务器A中的upload.php(upload.php目的地是服务器B)。
是这个问题吗?如果出现这样的问题,可能是防火墙问题。但我使用的服务器都是centos。然后我要做的是,关闭selinux,并使用firehol来调整我的centos中的防火墙。然后就可以正常工作了。
其他选项,您仍然可以在服务器 A 中接收文件。然后在接收中通过 ftp 将文件传输到服务器 B,但我认为这需要更多努力。因为您需要调整 ftp 配置(是 ftp、sftp 还是使用 pem / pkk 的 sftp)。
I think I have ever experience this problem. If I am not wrong to understand your issue, my issue is like this. I create upload.php in server A and receive in server A too, let's say the file is receive.php (it works normally). Then I upload the receive file (receive.php) to server B, and modify the upload.php in server A (which is the upload.php destination's is server B).
Is it the issue? If the issue like this, it might be firewall issue. But the server that I use both of them is centos. What I do then is, I switch off selinux, and use firehol to adjust the firewall in my centos. Then it's work fine.
Other option, you can still receive file in your server A. Then in your receive you transfer the file via ftp to server B, but I think this need more effort to do. Cause you need to adjust the ftp configuration (is it ftp, sftp, or sftp using pem / pkk).