note 36745 rejected from function.ftp-put by vincent
| From: | vincent@php.net | Date: | Tue, 21 Oct 2003 09:41:29 +0000 |
| Subject: | note 36745 rejected from function.ftp-put by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58979@lists.php.net to get a copy of this message | ||
Note Submitter: julienlefevre@wanadoo.fr
----
I use this form to collect datas about the server, user and file I want to upload:
<body>
<form action="/proceedupload.php" method="post"
enctype="multipart/form-data" name="form1">
<p>FTP upload:</p>
<table width="400" border="0">
<tr>
<td width="127">FTP adress</td>
<td width="263"><input type="text"
name="txt_ftp_adress"></td>
</tr>
<tr>
<td>Username</td>
<td><input type="text" name="txt_user_name"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="txt_pwd"></td>
</tr>
<tr>
<td>Source file</td>
<td><input name="txt_file" type="file"></td>
</tr>
<tr>
<td> </td>
<td><input name="action" type="submit"
value="Transférer"></td>
</tr>
</table>
<p> </p>
</form>
Then I use this script to proceed to the upload:
<?php
$ftp_server = $_POST["txt_ftp_adress"];
$ftp_user_name = $_POST["txt_user_name"];
$ftp_user_pass = $_POST["txt_pwd"];
$destination_file = $_FILES["txt_file"]["name"];
$source_file = $_POST["txt_file"];
//Check variables
echo "$ftp_server\n";
echo "$ftp_user_name\n";
echo "$ftp_user_pass\n";
echo "$destination_file\n";
echo "$source_file\n";
echo "$txt_file";
// Connexion creation
$conn_id = ftp_connect($ftp_server);
echo "$conn_id\n";
// authentification avec nom de compte et mot de passe
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
echo "$login_result\n";
// vérification de la connexion
if ((!$conn_id) || (!$login_result)) {
echo "La connexion FTP a échoué!\n";
echo "Tentative de connexion à $ftp_server avec $ftp_user_name\n";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name\n";
}
// téléchargement d'un fichier
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// Vérification de téléchargement
if (!$upload) {
echo "Le téléchargement FTP a échoué!\n";
} else {
echo "Téléchargement de $source_file sur $ftp_server en $destination_file\n";
}
// fermeture de la connexion FTP.
ftp_close($conn_id);
?>
Locally, on my PC, it works well. But, on the remote server the file is present, but its size is
0Kb.
Do you have any idea about what is the pb.
If i use the user setting with IE, I can write or delete on the remote server.
The "echo "$txt_file";" commands returns me the temp folder.