This page is to login to the FTP site and upload pictures.

[insert_php]
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
{

//uploaded files
if($_POST[‘ftpcheck’]==2)
{

$f1ftp_user_name = $_SESSION[‘f1ftp_user_name’];
$ftpname = $_SESSION[‘f1ftp_user_name’];

$f1ftp_user_pass = $_SESSION[‘f1ftp_user_pass’];

$f1ftp_server=”ftp.flxibleowners.org”;
$f1conn_id = ftp_connect($f1ftp_server);
$f1login_result = ftp_login($f1conn_id, $f1ftp_user_name, $f1ftp_user_pass);
$f1ftpfolder = $_POST[‘ftpfolder’];

//making a folder
//$f1ftpfolder_exists = ftp_dir(‘ftp://ftp.flxibleowners.org/c/’);
$f1ftpdir = is_dir($f1ftpfolder);

if (is_dir(‘ftp://’ . $ftpname . ‘:’ . $f1ftp_user_pass . ‘@flxibleowners.org/’ . $f1ftpfolder))
{
$f1uploaderror .= “Folder ” . $f1ftpfolder . ” already exists, please choose a different folder name.”;
}else{
if(ftp_mkdir ($f1conn_id,$f1ftpfolder))
{

//make an array from files
foreach($_FILES[‘ftpfiles’][‘tmp_name’] as $key => $tmp_name ){
$f1ftpfile_name = strtoupper($_FILES[‘ftpfiles’][‘name’][$key]);
$f1ftpfile_size =$_FILES[‘ftpfiles’][‘size’][$key];
$f1ftpfile_tmp =$_FILES[‘ftpfiles’][‘tmp_name’][$key];
$f1ftpfile_type=strtoupper($_FILES[‘ftpfiles’][‘type’][$key]);
$f1coverpicFileType = pathinfo($f1ftpfile_name,PATHINFO_EXTENSION);
//check file is image
$f1checkcover = getimagesize($_FILES[‘ftpfiles’][‘tmp_name’][$key]);
if($f1checkcover == false) {
$f1uploaderror .= “\n” . “File ” . $ftpfile_name . ” is not an image.”;
} else {

// Allow certain file formats
if(($f1coverpicFileType != “JPG”) && $f1coverpicFileType != “PNG” && $f1coverpicFileType != “JPEG”
&& $f1coverpicFileType != “GIF” && $f1coverpicFileType != “BMP”) {
$f1uploaderror .= “
File ” . $f1ftpfile_name . ” is not a support file type, only JPG, JPEG, PNG, BMP and GIF files are allowed.”;
}else{
//check max size
if($_FILES[‘image’][‘size’][$key] > 10485760){
$f1uploaderror .=’\n File ‘ . $fiftpfile_name . ‘ size must be less than 10 MB’;
}else{

if (ftp_put($f1conn_id, $f1ftpfolder . ‘/’ . $f1ftpfile_name,$f1ftpfile_tmp, FTP_BINARY)) {
$f1ftpfile .= “\n” . $f1ftpfile_name;
$f1ftpresult .= ‘
‘ . $f1ftpfile_name;
}
else{

$f1ftpresult .= “Folder ” . $f1ftpfolder . ” already exists, please choose a different folder name.”;
}}//end of making a folder

}}
}// end check max size
}//end allow certain file formats
}//end check file is image
//send email notification
$f1mailsend=’Y’;
if ($f1mailsend ==”Y”) {
$f1to = “adoptaflx@flxibleowners.org”;
$f1noreply = “noreply@flxibleowners.org”;
$f1from = $f1ftp_user_name;
$f1mailfirst_name = “Pictures”;
$f1subject = “New Pictures Uploaded”;
$f1messagecopy1 = $f1from . ” has uploaded (or tried to upload) pictures to the ” . $f1ftpfolder .” folder. ” . “\n\n” . “Files uploaded :” . $f1ftpfile;

$f1messagecopy = “Thanks for contacting us. We will be working on getting your bus listed shortly. If you have any questions or need to change any of the information below, please contact us at adoptaflx@flxibleowners.org.” . “\n\n” . “Contact Name: ” . $f1contact . “\n\n” . “Phone: ” . $f1phone . “\n\n” . “Email: ” . $f1cemail . “\n\n” . “City: ” . $f1city . “\n\n” . “State: ” . $f1state . “\n\n” . “Zip Code: ” . $f1zip . “\n\n” . “Country: ” .$f1country . “\n\n” . “Bus Model: ” . $f1model . “\n\n” . “Bus Birth Year: ” . $f1busyear . “\n\n” . “Bus Description: ” . $f1busdescription . “\n\n” . “Asking Price: ” . “$” . $f1price . “\n\nThanks\nAdopt-A-Flx\nhttp://www.flxibleowners.org”;

$f1headers = “From:” . $f1from;
$f1headers2 = “From:” . $f1noreply;
mail($f1to,$f1subject,$f1messagecopy1,$f1headers);
//mail($f1from,$f1subject,$f1messagecopy,$f1headers2);
}

echo “

These files have been successfully uploaded :” . $f1ftpresult . “

“;
echo ‘
‘;
echo “

” . $f1uploaderror . “

“;
echo ‘
‘;
//check = 1 to pull back upload file form.
$check=1;
ftp_close($f1conn_id);
}//end if ftpcheck = 2

//logged in
if($_POST[‘ftpcheck’]==1)
{
$f1ftp_server=”ftp.flxibleowners.org”;
$f1ftp_user_name=$_POST[‘ftpuser_name’];
$f1ftp_user_pass=$_POST[‘ftppass’];
$f1conn_id = ftp_connect($f1ftp_server);
if (@ftp_login($f1conn_id, $f1ftp_user_name, $f1ftp_user_pass))
{
$check = $_POST[‘ftpcheck’];
$_SESSION[‘f1ftp_user_name’]= $f1ftp_user_name;

$_SESSION[‘f1ftp_user_pass’]= $f1ftp_user_pass;

}
else
{
$check = 0;
echo ‘

Invalid Username or Password

‘;
}
}

}
else
{
$check = 0;
}
echo $ftp_result;
if($check==0)
{
unset ($_SESSION[‘f1ftp_user_name’]);
unset ($_SESSION[‘f1ftp_user_pass’]);
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

User Name :
Password :

‘;
}
if($check==1)
{
if ($ftpname ==”){
$ftpname = $_POST[‘ftpuser_name’];
}
echo “Welcome ” . $ftpname . “, Please upload pictures below. To select multiple files to upload, hold the Ctrl key and click the files you would like to upload.
Please note that only the following image formats are supported: jpeg, jpg, png, gif, and bmp.”;
echo ‘
Logout‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

Files to upload :
Name of folder to put files in :

‘;
}
if($_POST[‘check’] > 0)
{
echo ‘test’;
}
[/insert_php]