yo hice un codigo que lo que hace es que lo sube a un temporal y luego lo manda por ftp a otro host.
(esto porque asi me lo pidieron)
Chequea extension y tamaño del archivo.
$local_dir = "TU_DIRECTORIO_DE_ARCHIVOS";
// check if file was submited
if($_FILES['file']['name'] != ''){
// Configuration - Your Options
$allowed_filetypes = array('.doc','.pdf','.docx'); // These will be the types of file that will pass the validation.
$max_filesize = 1048576; // Maximum filesize in BYTES (currently 1MB).
//$upload_path = './upload/'; // The place the files will be uploaded to (currently a 'upload' directory).
$filename = $_FILES['file']['name']; // Get the name of the file (including file extension).
$ext = strrchr($filename,'.'); // Get the extension from the filename.
// creating new file name
$new_file = 'resume_'.trimstring($first_name).'_'.trimstring($first_last_name).'_'.rand().$ext;
//**********************************************************
//************** SEND FILE TO FTP***************************
//**********************************************************
$error_var = false;
// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes)){
$error_msg = 'The file you attempted to upload is not allowed';
$error_var = true;
}
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['file']['tmp_name']) > $max_filesize){
$error_msg = 'The file you attempted to upload is too large.<br>Allowed file size < 1MB';
$error_var = true;
}
if(!$error_var){
// File is ok to upload
// get FTP access parameters
$host = $ftp_host;
$user = $ftp_user;
$pass = $ftp_pass;
$destDir = $ftp_dir;
$workDir = $local_dir; // define this as per local system
// get temporary file name for the uploaded file
$tmpName = basename($_FILES['file']['tmp_name']);
// copy uploaded file into current directory
//move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$new_file)
// or die("Cannot move uploaded file to working directory");
move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$new_file)
or die("Cannot move uploaded file to working directory");