|
Posted by Zoe Brown on 05/27/07 11:37
I have the following simple script. But I am getting the error message "FTP
upload failed!" Which is annoying. Why might this be ?
the files i have tried are tiny .txt and jpeg.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<?php
$upload = False;
if (array_key_exists('submit',$_POST))
{
$message = "";
$file = $_FILES['uploaded']['name'];
$ftp_server ="details removed";
$ftp_user_name = "details removed";
$ftp_user_pass ="details removed";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result))
{
echo "FTP connection has failed!<br>";
echo "Attempted to connect to $ftp_server for user
$ftp_user_name<br>";
exit;
}
else
{
echo "Connected to $ftp_server, for user $ftp_user_name<br>";
}
// upload the file
$upload = ftp_put($conn_id, $file, $file, FTP_ASCII);
// check upload status
if (!$upload)
{
echo "FTP upload has failed!<br>";
}
else
{
echo "Uploaded $source_file to $ftp_server as $file<br>";
$upload = True;
}
// close the FTP stream
ftp_close($conn_id);
}
?>
<body>
<?php if (!$upload) {?>
<p>Browse to the document you would like to upload.</p><form
enctype="multipart/form-data" method="post">
<input name="uploaded" type="file" /><br>
<input type="submit" name="submit" value="GO"/>
</form>
<?php }?>
</body>
</html>
Navigation:
[Reply to this message]
|