by rschroers on Mon Jun 29, 2009 3:31 pm
Hi Adam,
here is the code for the 'uploader.php';
If files are larger than 100kb the $upload is false.
Regards,
Ralf
<?php session_start();
if ($_SESSION['sess_var'] == "ftp_session"){
$target_path = "client_ftp/";
$paths=$_POST['pathserver'];
$filep=$_FILES['uploadedfile']['tmp_name'];
$ftp_server= "ftp.xyz.com.au";
$ftp_user_name= "zyx.com.au";
$ftp_user_pass= "blah";
$name=$_FILES['uploadedfile']['name'];
// set up a connection to ftp server
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection and login result
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has encountered an error!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name....";
exit;
} else {
# echo "Connected to $ftp_server, for user $ftp_user_name".".....";
}
// upload the file to the path specified
switch($_FILES['uploadedfile']['type']) {
case "image/gif":
case "image/png":
case "image/jpeg":
case "image/bmp":
case "image/tif":
$upload = ftp_put($conn_id, $paths.'/'.$name, $filep, FTP_BINARY);
break;
default:
$upload = ftp_put($conn_id, $paths.'/'.$name, $filep, FTP_ASCII);
};
// check the upload status
if (!$upload) {
echo "FTP upload has encountered an error!";
} else {
echo "Uploaded file with name $name to $ftp_server ";
}
// close the FTP connection
ftp_close($conn_id);
}
else echo'</table><div style="padding-top:10px"><h3>Not Authorised.</h3></div>';
session_destroy();
?>