'path/to/', 'dropzone_text'=>'D&D here !', 'dropzone_id'=>'drop_images', 'dropzone_class'=>'drop_images', 'forbidden_filetypes'=>'exe,php', 'use_style'=>true, // false if you're using an css file ); 'destination_filepath' key:'destination_filepath'=>"$_SESSION['upload_root_path']/" (with ending slash) if not specified, the destination folder will be destination/ (created on the first start) you also can set specific paths for each mime type like that 'destination_filepath'=>array('gif'=>'path/to/gif/','png'=>'path/to/png/' ... ) 'forbidden_filetypes' key: restrict allowed filetypes (separated with ,) ---------------------------------------------- * this is the default config */ // Configuration $phpini=ini_get_all(); $default_config=array( 'forbidden_filetypes'=>'php', 'allow_unknown_filetypes'=>$allow_unknown_filetypes, 'use_style'=>false, // false if you're using a external css file 'auto_refresh_after_upload'=>true, // auto refresh page after uploading files (except on errors) 'max_length'=>2048, // Mo (see php.ini if changes doesn't work [post_max_size / upload_max_filesize]) 'dropzone_text'=>e('Drop your files here or click to select a local file',false), 'dropzone_id'=>'dropArea', 'dropzone_class'=>'dropArea', 'destination_filepath'=>$_SESSION['current_path'].'/', // this can be an array like 'jpg'=>'upload/jpeg/' or a string 'destination/' 'my_filepath'=>'index.php'//$_SERVER['SCRIPT_NAME'], ); foreach($default_config as $key=>$val){ // create or complete config var if(!isset($auto_dropzone[$key])){ $auto_dropzone[$key]=$auto_dropzone[$key]=$val;} // has config changed ? if (!isset($_SESSION[$key]) || $auto_dropzone[$key]!=$_SESSION[$key]){ $_SESSION[$key]=$auto_dropzone[$key];} } if (!is_array($auto_dropzone['destination_filepath'])&&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'])){ mkdir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'],0744);file_put_contents($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'].'index.html',''); } // Handle the unit (M/G) in max post/upload size $ini_max_upload=$phpini['upload_max_filesize']['global_value']; if (strpos($ini_max_upload,'G')!=false){$ini_max_upload=intval($ini_max_upload*1024);} else{$ini_max_upload=intval($ini_max_upload);} $ini_max_post=$phpini['post_max_size']['global_value']; if (strpos($ini_max_post,'G')!=false){$ini_max_post=intval($ini_max_post*1024);} else{$ini_max_post=intval($ini_max_post);} $max=min($auto_dropzone['max_length'],$ini_max_upload,$ini_max_post); $_SESSION['max_size']=$max; $file_length_error=e('Error, max filelength:',false).' '.$max.' Mo'; $file_format_error=e(': Error, forbidden file format !',false); $auto_dropzone_error=false; // uploading files if (!empty($_FILES)){ // HANDLE UPLOAD function bytesToSize1024($bytes, $precision = 2) { if (!empty($bytes)){ $unit = array('B','KB','MB'); return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i]; }else{return false;} } function error2msg($e){ if ($e>0&&$e<7){ $errors=array( 1=>e('The file to big for the server\'s config',false), 2=>e('The file to big for this page',false), 3=>e('There was a problem during upload (file was truncated)',false), 4=>e('No file upload',false), 5=>e('No temp folder',false), 6=>e('Write error on server',false), ); return $errors[$e]; }else if ($e>7){return true;} else{return false;} } function secure($file){ return preg_replace('#(.+)\.php#i','$1.SPHP',$file); } if (isset($_FILES['myfile']) && strtolower($_FILES['myfile']['name'])!="index.html") { $sFileName = secure($_FILES['myfile']['name']); $sFileType = $_FILES['myfile']['type']; $sFileSize = intval(bytesToSize1024($_FILES['myfile']['size'], 1)); $sFileError = error2msg($_FILES['myfile']['error']); $sFileExt = pathinfo($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,PATHINFO_EXTENSION); ######################################################################### # ADDED FOR BOZON ######################################################################### if (!function_exists('folder_fit')){include($path_core.'core.php');} if (!folder_fit(null,$_FILES['myfile']['size'],$_SESSION['login'])){ # uploaded file doesn't fit in user's folder if (!isset($_SESSION['ERRORS'])){$_SESSION['ERRORS']='';} $error='
  • '.$sFileName.' ['.$sFileType.', '.$sFileSize.'] '.e('The file doesn\'t fit',false).'
  • '; $_SESSION['ERRORS'].=$error; exit($error); } ######################################################################### $ok='
  • '.$sFileName.' ['.$sFileType.', '.$sFileSize.'] [OK]
  • '; $notok='
  • '.$sFileName.' ['.$sFileType.', '.$sFileSize.'] '.e('Upload error',false).'
  • '; if ( is_array($auto_dropzone['destination_filepath']) &&!empty($auto_dropzone['destination_filepath'][$sFileExt]) &&is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'][$sFileExt]) ){ $sFileName = $auto_dropzone['destination_filepath'][$sFileExt].$sFileName; echo $ok; rename($_FILES['myfile']['tmp_name'], $_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName ); chmod($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,0644); }elseif( is_array($auto_dropzone['destination_filepath']) &&!empty($auto_dropzone['destination_filepath'][$sFileExt]) &&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'][$sFileExt]) || is_string($auto_dropzone['destination_filepath']) &&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath']) ){ //local upload dir error echo '
  • Upload path problem with '.$sFileName.'
  • '; }elseif($sFileError){ // file upload error echo '
  • '.$sFileName.': '.$sFileError.'
  • '; } elseif(is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'])){ $file=$sFileName; $sFileName = $auto_dropzone['destination_filepath'].$sFileName; if (is_file($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName)){ $newfilename=rename_item($file,$_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath']); echo '
  • '.$file.' => '.$newfilename.'
  • '; $sFileName=$auto_dropzone['destination_filepath'].$newfilename; } echo $ok; rename($_FILES['myfile']['tmp_name'], $_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName ); chmod($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,0644); $id=addID($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName); $tree=add_branch($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,$id,$_SESSION['login'],$tree); } } else { echo $notok; } exit(); }else{ // GENERATE DROPZONE if ($auto_dropzone['use_style']){ echo ' '; } ?>