Help,
I have written a funciton that will upload a file to the remote server but when the script gets to the ftp_put() it stops and displays the error message. The script is in a file called send.php and is in a directory called includes/. I have googling for some answers but nothing has worked.
// ====================================================
// ===============================================================
// function upload resume
// ===============================================================
function uploadResume ($resume,$email) {
$mydir = "/www/www/resumes/";
$myemail = $email;
$myresume = $resume;
//==================================================
// remove extension of email for new resume name
//==================================================
$mylen = strlen($myemail) - 4;
$myemail = substr($myemail,0,$mylen);
// =================================================
// create ftp connection
// =================================================
$connection["username"] = "urbanpro";
$connection["password"] = "33280405";
$connection["server"] = "urbanprograms.com";
$connection["id"] = ftp_connect($connection["server"]);
$connid = $connection['id'];
if (!($connid)) {
die ("Error++: Could not connect to server: SEND:ftpConn");
}
$login = ftp_login($connection["id"],$connection["username"],$connection["password"]);
if (!($login)) {
die ("Error: Could not connect to server: SEND:ftpConn");
//return false;
}
//==================================================
// check size of resume
// =================================================
$mysize = ftp_size($connid,$myresume);
echo "================ ".$mysize." ===========<br>";
if ($mysize >= 50000) {
die ("Error: The size of the resume cannot exceed 50 Kb: SEND:uploadResume");
}
//==================================================
// get the extention of the resume
//==================================================
$myext = strlen($myresume) - 3;
$myext = substr($myresume,$myext,3);
if (!($myext)) {
die ("Error: string extension: SEND:uploadResume");
}
switch ($myext) {
CASE "doc":
$myresume = "{$myemail}.{$myext}";
break;
CASE "pdf":
$myresume = "{$myemail}.{$myext}";
break;
CASE "rtf":
$myresume = "{$myemail}.{$myext}";
break;
CASE "txt":
$myresume = "{$myemail}.{$myext}";
break;
default:
die ("Error: Unknown file type: SEND:uploadResume");
break;
} // end switch
// =================================================
// change mode to passive
// =================================================
$call = ftp_pasv($connid,1);
// =================================================
// change the direcotory permission to upload
// ==============================================
$mychmod = ftp_site($connid,"CHMOD 777 {$mydir}");
if (!($mychmod)) {
die ("Error: permissions not set to upload: SEND:uploadResume");
}
// ================================================
// change directories to /www/www/resumes/
// ================================================
$uploaddir = ftp_chdir($connid,$mydir);
if (!($uploaddir)) {
die ("Error: could not change directories: SEND:uploadResume");
}
// ================================================
// AAAAHHHHHH! finally upload the resume
// =================================================
$cwd = getcwd();
echo "======== ".$myresume." ======== ".$cwd." ===+++++===== ".$resume." ===<br>";
$uploadresume = ftp_put($connid,$myresume,$resume,FTP_ASCII);
if (!($uploadresume)) {
die("Error: There was an error uploading the resume: SEND:uploadResume");
}
// ================================================
// reset directory persmission
// =================================================
$mychmod = ftp_site($connid,"CHMOD 644 {$mydir}");
if (!($mychmod)) {
die ("Error: could not reset permissions: SEND:uploadResume");
}
// ================================================
// cloase the ftp connection
// ===============================================
$call = ftp_close($connid);
if (!($call)) {
die ("Error: could not close ftp connection: SEND:uploadResume");
}
return $myresume;
} // end function upload resume