upload file using ftp_raw or fsock instead of ftp_put ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
altnen
Forum Newbie
Posts: 1
Joined: Fri Feb 01, 2008 8:52 am

upload file using ftp_raw or fsock instead of ftp_put ??

Post by altnen »

hi

i want to upload file using ftp, i found some working code like this

Code: Select all

 
<?php
 
    function uploadFile($filename,$filename) {
        $conn_id = ftp_connect("host");
        ftp_login($conn_id, "user", "pass");
        ftp_put($conn_id, "$filea_name", "$filename", FTP_BINARY);
        ftp_quit($conn_id);
        
        return $file_name;
    }
 
    $file_name      = $_POST['file_name'];
    $file_desc      = str_replace(chr(13),"<br>", $_POST['file_desc']);
    $filename       = $_FILES['FILENAME']['tmp_name'];
    $filename_name  = $_FILES['FILENAME']['name'];
    $filename_type  = $_FILES['FILENAME']['type'];
    $filename_size  = $_FILES['FILENAME']['size'];
    
    $file_source    = uploadFile($filename,$filename_name);
 
?>
 
but the problem that i want to read the server response as ftp clients show

Code: Select all

 
COMMAND:>   [01/02/2008 04:48:33 ?] CWD /cadpic.gif
        [01/02/2008 04:48:33 ?] 550 /cadpic.gif: No such file or directory
STATUS:>    [01/02/2008 04:48:33 ?] Requested action not taken (e.g., file or directory not found, no access).
COMMAND:>   [01/02/2008 04:48:33 ?] CWD /
        [01/02/2008 04:48:34 ?] 250 CWD command successful
STATUS:>    [01/02/2008 04:48:34 ?] PWD skipped. Current folder: "/".
COMMAND:>   [01/02/2008 04:48:34 ?] PASV
        [01/02/2008 04:48:34 ?] 227 Entering Passive Mode (00,000,00,00,223,133).
COMMAND:>   [01/02/2008 04:48:34 ?] STOR cadpic.gif
STATUS:>    [01/02/2008 04:48:34 ?] Connecting FTP data socket... 00.000.00.00:57221...
        [01/02/2008 04:48:38 ?] 150 Opening BINARY mode data connection for cadpic.gif
        [01/02/2008 04:48:44 ?] 226 Transfer complete.
 
ftp_raw returns this response but i couldn't use it to upload files ?? how can i do it or is there any better way to upload ang get the response?
Post Reply