Forum Moderators: coopster
if (isset($_POST['Submitted'])) {
header('Content-type: image/jpeg');
$location = $_SERVER['DOCUMENT_ROOT'].'/common/pictures/';
$newFile = "test.jpg"; //$this->generateImageName($image).".".$this->getImageType($image);
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id,$login,$password);
// check connection
if ((!$conn_id) ¦¦ (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected to Server!<br/>";
}
echo "File Destination: ". $location.$newFile."<br /> ";
echo "Temporary File: ". $_FILES["userfile"]["tmp_name"];
$upload = ftp_put($conn_id, $location.$newFile, $_FILES["userfile"]["temp_name"], FTP_BINARY);
// check upload status
if (!$upload) {
echo "Ftp upload has failed!";
} else {
echo "Uploaded successful";
}
ftp_close($conn_id);
}
output:
Connected to Server!<br/>File Destination: /usr/local/psa/home/vhosts/ksmarket.com/httpdocs/common/pictures/test.jpg<br /> Temporary File: /tmp/php0bX9Qk<br />
<b>Warning</b>: ftp_put(): /usr/local/psa/home/vhosts/example.com/httpdocs/common/pictures/test.jpg: No such file or directory in <b>/usr/local/psa/home/vhosts/example.com/httpdocs/admin/main/items/add.php</b> on line <b>31</b><br />
Ftp upload has failed! the permission for the /common/pictures/ directory is set to 777.
thanks all for the help
[edited by: coopster at 12:26 pm (utc) on May 7, 2005]
[edit reason] generalized site specifics in directory path [/edit]