开发者

Saving file to remote domain

开发者 https://www.devze.com 2023-02-25 20:00 出处:网络
I\'d like to host an uploading script on one server but have it store the uploaded files to a remote server.

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 per开发者_Python百科missions 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!


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.


Try in via ftp

http://php.net/manual/de/book.ftp.php


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号