Help with FTP Upload
Posted: Wed Jun 18, 2008 5:12 pm
Code: Select all
<?php
$directory = "/public/images/";
$tempdir='/tmp/';
$filo=$_FILES['thefile']['name'];
$username = (ftp username);
$pass= (ftp pass);
$servero = (ftp servername);
$connection = ftp_connect($servero) or die("<p>Could not connect to server</p>");
ftp_login($connection, $username, $pass) or die("<p>Could not log in to server</p>");
$server_file = basename($_FILES['thefile']['tmp_name']);
$loco_file = basename($_FILES['thefile']['name']);
$tottemp=$tempdir.$server_file;
$totloc = $thedir."\\".$filo;
ftp_chdir($connection,$directory) or die("<p>Could not change directory</p>");
chmod($tottemp, 0777) or die("<p>Could not change permissions</p>");
ftp_put($connection, $filo, $tottemp, FTP_BINARY) or die(mysql_error());
ftp_close($connection);
?>"Warning: ftp_put() [function.ftp-put]: Unable to build data connection: No route to host"
A file is created in /public/images/, but the size is 0kb. Destination folder is 0777... also tried with my firewall disabled... this was working for me then seemed to just suddenly stop... also tried using a PHP Flex server...
Thanks