Page 1 of 1

FTP upload question

Posted: Mon Mar 30, 2009 9:30 am
by lammspillning
When this is on my server, how would I write the path ($source_file) to a file on my local computer?
And how can I put the file inside my created folder?

Code: Select all

<?php
// set up basic connection
$conn_id = ftp_connect("ftp.mysite.com"); 
 
// login with username and password
$login_result = ftp_login($conn_id, "user", "pass"); 
 
// check connection
if ((!$conn_id) || (!$login_result)) { 
        echo "Failed!";
        exit; 
    } else {
        echo "Connected";
    }
 
$source_file = 'path to my file on local computer';
$destination_file = 'destinationName.avi';
 
// Destination directory
$dir = $_SERVER['DOCUMENT_ROOT'].'/uploadedFiles/'; 
 
// Make directory
$newFolder = mkdir($dir.'myFolder',0777);
 
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 
 
// check upload status
if (!$upload) { 
        echo "FTP upload has failed!";
    } else {
        echo "Uploaded";
    }
 
// close the FTP stream 
ftp_close($conn_id); 
?>