Hjælp til simpelt php ftp script
Hej Eksperter!Jeg er ved at lave et "simpelt" FTP script i PHP, hvor brugeren via en form skal kunne uploade filer i biblioteket "www.domæne.dk/anemonen/txt"
Jeg kan dog ikke helt få hul igennem - hvad mangler jeg?
<?
if ($cdir==upload) {
$server='www.xxx.dk';
$username='xxx';
$password='xxx';
// function to connect to FTP server
function connect()
{
global $server, $username, $password;
$conn = ftp_connect($server);
ftp_login($conn, $username, $password);
return $conn;
}
$dst_dir='/www/anemonen/txt/';
$result = connect();
// $upload = ftp_put($result, $dst_dir."/".$file, $file, FTP_BINARY);
$upload = ftp_put($result, $file_name, $file, FTP_BINARY);
// check status and display
if ($upload == 1)
{
$status = "Upload successful!";
}
else
{
$status = "Upload error!";
}
} else {
?>
<!-- file upload form -->
Kopier filer:
<form enctype="multipart/form-data" action="<?php echo($PHP_SELF); ?>" method=post>
<table>
<tr>
<td>
<!-- file selection box -->
<input type=file name=file>
<input type=hidden name=cdir value=upload>
</td>
</tr>
<tr>
<td>
<!-- action for this form -->
<input type=submit name=action value=Kopier filer>
</td>
</tr>
</table>
</form>
<?
}
?>