/    Sign up×
Community /Pin to ProfileBookmark

Copy File using FTP

Dear Developer,
i tried this code below :

[CODE]
<?php

$ftp_server=’172.16.0.44′;//serverip
$conn_id = ftp_connect($ftp_server,8021);

// login with username and password
$user=”artemis”;
$passwd=”baltazhor200401″;
$login_result = ftp_login($conn_id, $user, $passwd);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection has failed!”;
echo “Attempted to connect to $ftp_server for user $ftp_user_name”;
die;
} else {
echo “<br>Connected to $ftp_server, for user $user<br>”;
}

if(isset($_POST[‘Submit’])){
$upload = ftp_put($conn_id, “upload/”.$_FILES[‘file’][‘name’], $_FILES[‘file’][‘tmp_name’], FTP_BINARY);
if (!$upload) {
echo “FTP upload has failed!”;
} else {
echo “Uploaded $source_file to $ftp_server as $destination_file”;
}
}
ftp_close($conn_id);
?>
<table width=”100″ border=”0″ cellspacing=”1″ cellpadding=”1″>
<form name=”form1″ method=”post” action=”test_ftp.php” enctype=”multipart/form-data”>
<tr>
<td width=”52″ nowrap>File</td>
<td width=”10″ nowrap>:</td>
<td width=”28″ nowrap><input type=”file” name=”file”></td>
</tr>
<tr>
<td nowrap>&nbsp;</td>
<td nowrap>&nbsp;</td>
<td nowrap><input type=”submit” name=”Submit” value=”Copy”></td>
</tr>
</form>
</table>
[/CODE]

but then i found this error :
[B]Warning: ftp_put() [function.ftp-put]: Opening data channel for file transfer. in ***[/B]

could you tell me why ?

Thanks

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @baltazhor200401 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.19,
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,
)...