Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   [php]FTP upload script (https://thetfp.com/tfp/tilted-technology/86057-php-ftp-upload-script.html)

pixelbend 03-24-2005 01:05 PM

[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);

?>

I get the "FTP upload has failed!" on all files except upload.php and upload.html

theFez 03-26-2005 08:18 PM

I guess what look suspicious to me is you are using ftp to connect to a mail server. Is this really what you want to do?

skaven 04-07-2005 08:04 AM

Check your apache error log. Usually there will be some more verbose information there.

pixelbend 04-07-2005 09:00 AM

Got it working. I was not using the proper front end (that was my main problem anyway) on the html side.


All times are GMT -8. The time now is 09:24 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47