/    Sign up×
Community /Pin to ProfileBookmark

Could you please help me.

I am a newbie PHP developer, I have this problem:

I want to create a script that will transfer/upload file from the server where the script is uploaded, to my other sites.

Is it possible? if so could you please give a sample code how to do it please.

Thanks in advance ?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@MstrBobOct 10.2004 — PHP is meant for dealing with client/server connections. It isn't for server/server connections. You can't simply write to another server, that would be a big security whole. You're best bet is to get an FTP program, like Filezilla, and download the files onto your computer, and then FTP them to your sites.
Copy linkTweet thisAlerts:
@yunaOct 12.2004 — There are FTP client functions in PHP (http://us2.php.net/ftp) and, as that page points out, you can also use ftp:// URLs with many filesystem functions. So it's certainly possible for one to write a script a server that uploads files to another. Of course you have to make sure authentication works, etc. The simplest way is to specify URLs like this
<i>
</i><a href="ftp://user:[email protected]/upload/directory/">ftp://user:[email protected]/upload/directory/</a>

but that's a big security hole since the password has to be stored in plaintext on the machine making the upload request. You could put the password in a separate file that only the webserver "user" can read ("security through obscurity"), or use anonymous FTP on the target host. In the latter case, I'd make sure you have strict firewalling rules on the target allowing only the uploading server's IP address to access the target's FTP port.
Copy linkTweet thisAlerts:
@NogDogOct 12.2004 — Check out http://www.php.net/ftp and in particular "Example 1". You could keep $ftp_user_name and $ftp_user_pass relatively secure by setting them in an include file which is kept in a secure directory. (However, note the installation instructions on the above-cited page.)
×

Success!

Help @edpudol spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...