Forum Moderators: coopster
This is a weird problem. At the risk of spamming my code and iritating people, in order to save time, I will go ahead an post the code for this script.
//HMTL
<form>
<input type=file name=target_file>
<input type=submit name=submit_file>
</form>//php
$SUBMIT_FILE = $_POST['SUBMIT_FILE'];
if($SUBMIT_FILE)
{
$filename = $_FILES['UPLOADED_FILE']['name'];
$filesize = $_FILES['UPLOADED_FILE']['size'];
$ftp_server = "server";
$ftp_login = "user";
$ftp_pass = "pass";
$remote_path = "remote_path/ftp_uploads";
if(($filename==NULL)&&($filesize==NULL))
echo "<font color=\"#D20000\">ERROR:</font> Please select a valid file to upload.<br>";
else
{ $ftp_connection_handle = ftp_connect($ftp_server, 21);
if(!$ftp_connection_handle)
echo "<font color=\"#D20000\">ERROR:</font> Could not establish an ftp connection.<br>";
$ftp_login_handle = ftp_login($ftp_connection_handle, $ftp_login, $ftp_pass);
if(!$ftp_login_handle)
echo "<font color=\"#D20000\">ERROR:</font> Could not successfully login to ftp server.<br>";
ftp_pasv($ftp_connection_handle, true);
if(ftp_put($ftp_connection_handle, $remote_path.$filename, $filename, FTP_BINARY))
echo "File <b>$filename</b> uploaded successfully in BINARY format.<br>";
else if(ftp_put($ftp_connection_handle, $remote_path.$filename, $filename, FTP_ASCII))
echo "File <b>$filename</b> uploaded successfully in ASCII format.<br>";
else
echo "<font color=\"#D20000\">ERROR:</font> File <b>$filename</b> was not uploaded.<br>";
$server_OS = ftp_systype($ftp_connection_handle);
echo "<br><br><u>File info</u><br>File: $filename<br>Size: $filesize";
echo "<br><br><u>Server info</u><br>Server OS: $server_OS";
ftp_close($ftp_connection_handle);
}
}
Sry, I know that makes for a long post. But can anyone lend some ideas? I've been pouring over it for quite some time. I don't know ... might be something simple.
Thanks,
Josh
P.S. I tried putting all the code inside the [code] tags, but apparently didn't work
<?php
$SUBMIT_FILE = (isset($_POST['SUBMIT_FILE']))? $_POST['SUBMIT_FILE'] : '';
if ($SUBMIT_FILE) {
$filename = $_FILES['UPLOADED_FILE']['name'];
$filesize = $_FILES['UPLOADED_FILE']['size'];
$ftp_server = "server";
$ftp_login = "user";
$ftp_pass = "pass";
$remote_path = "remote_path/ftp_uploads";
if (($filename==NULL) && ($filesize==NULL)) {
echo "<font color=\"#D20000\">ERROR:</font> Please select a valid file to upload.<br>";
} else {
$ftp_connection_handle = ftp_connect($ftp_server, 21);
}
if (!$ftp_connection_handle) {
echo "<font color=\"#D20000\">ERROR:</font> Could not establish an ftp connection.<br>";
}
$ftp_login_handle = ftp_login($ftp_connection_handle, $ftp_login, $ftp_pass);
if (!$ftp_login_handle) {
echo "<font color=\"#D20000\">ERROR:</font> Could not successfully login to ftp server.<br>";
}
ftp_pasv($ftp_connection_handle, true);
if (ftp_put($ftp_connection_handle, $remote_path.$filename, $filename, FTP_BINARY)) {
echo "File <b>$filename</b> uploaded successfully in BINARY format.<br>";
} else if (ftp_put($ftp_connection_handle, $remote_path.$filename, $filename, FTP_ASCII)) {
echo "File <b>$filename</b> uploaded successfully in ASCII format.<br>";
} else {
echo "<font color=\"#D20000\">ERROR:</font> File <b>$filename</b> was not uploaded.<br>";
}
$server_OS = ftp_systype($ftp_connection_handle);
echo "<br><br><u>File info</u><br>File: $filename<br>Size: $filesize";
echo "<br><br><u>Server info</u><br>Server OS: $server_OS";
ftp_close($ftp_connection_handle);
}
?>