03-24-2005, 01:05 PM | #1 (permalink) |
Too hot in the hot tub!
|
[php]FTP upload script
Hi all,
I am writing an FTP upload script and I'm having a weird problem. I wrote it and tested it by uploading the html and php files that make up the script. It will transfer either of those fine, but any other file I try errors out. Heres the code: Code:
<?php //Magna-Tel FTP Upload site //get variables from form $cust = $_POST["customer"]; $name = $_POST["name"]; $email = $_POST["email"]; $ponum = $_POST["ponum"]; $file = $_POST["file"]; $dest_file = $ponum . "_" . $file; //Check to see all input is present if ($cust == "") echo "<p>Customer name missing!"; else if($name == "") echo "<p>Name missing!"; else if($email == "") echo "<p>Email missing!"; else if($file == "") echo "<p>File name missing!"; //Connect to ftp server $ftp_server = "pop3.magna-tel.net"; $ftp_user_name = "ftpuser"; $ftp_user_pass = "upload"; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "<p>FTP connection has failed!"; echo "<p>Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "<p>Connected to $ftp_server, for user $ftp_user_name"; } // upload the file $upload = ftp_put($conn_id, $dest_file, $file, FTP_BINARY); // check upload status if (!$upload) { echo "<p>FTP upload has failed!"; } else { echo "<p>Uploaded $file to $ftp_server as $dest_file"; } // close the FTP stream ftp_close($conn_id); //Email art@magna-tel.net and customer with notice $art_email = "art@magna-tel.net"; $art_subject = "FTP file has been uploaded"; $art_body = "$name from $cust has uploaded file $file to the FTP server.\nPlease check as soon as possible."; $art_return = "From:davidg@magna-tel.net"; if ($upload) mail ($art_email, $art_subject, $art_body, $art_return); ?>
__________________
But I don't want ANY Spam! |
Tags |
phpftp, script, upload |
|
|