$val){ //upload and stored images $target_dir = "../../attachment/".date('Y-m')."/"; // $target_dir = "../../attachment/2017-07/"; if ( !file_exists($target_dir) ) { mkdir($target_dir,0777); chmod($target_dir,0777); } $file_org_name = $_FILES[$upload_name]['name'][$key]; $file_size = $_FILES[$upload_name]['size'][$key]; $save_path = $target_dir; $path_info = pathinfo($_FILES[$upload_name]['name'][$key]); $file_extension = strtolower($path_info["extension"]); $file_name = time().genRandomString(5,1,1,1).'.'.$file_extension; $target_file = $target_dir.$file_name; $boxID = 'upload_'.md5(date('Y-m-d H:i:s ').$file_org_name); // echo '
'; // echo $file_org_name.'
File uploading... '; // echo '
'; if ( isset($_POST['resize']) && $_POST['resize'] != '' ) { $reSize = explode(';',$_POST['resize']); foreach($reSize as $re) { $r = explode(',',$re); $resizeName = $r[0]; $maxWidth = $r[1]; $maxHeight = $r[2]; if(preg_match("/^[a-z]*$/",$resizeName) && is_numeric($maxWidth) && is_numeric($maxHeight)) { if($resizeName=='original') { $srcCD = 'ResizeImg( '; $srcCD.= $_FILES[$upload_name]['tmp_name'][$key]; $srcCD.= ', '.$_FILES[$upload_name]['tmp_name'][$key]; $srcCD.= ', '.$maxWidth; $srcCD.= ', '.$maxHeight; $srcCD.= ')'; // fShowCD($srcCD); ResizeImg( $_FILES[$upload_name]['tmp_name'][$key] , $_FILES[$upload_name]['tmp_name'][$key] , $maxWidth , $maxHeight , ( $resizeName != 'thumb' ) ); } else { $resize_save_path = $save_path.$resizeName.'/'; if(!is_dir($resize_save_path)) { mkdir($resize_save_path,0777); chmod( $resize_save_path,0777 ); } $srcCD = 'ResizeImg( '; $srcCD.= $_FILES[$upload_name]['tmp_name'][$key]; $srcCD.= ', '.$resize_save_path.$resizeName.'_'.$file_name; $srcCD.= ', '.$maxWidth; $srcCD.= ', '.$maxHeight; $srcCD.= ')'; // fShowCD($srcCD); ResizeImg( $_FILES[$upload_name]['tmp_name'][$key] , $resize_save_path.$resizeName.'_'.$file_name , $maxWidth , $maxHeight , ( $resizeName != 'thumb' ) ); if ( !file_exists($resize_save_path.$resizeName.'_'.$file_name) ) { // fShowCD('copy('.$_FILES[$upload_name]['tmp_name'][$key].','.$resize_save_path.$resizeName.'_'.$file_name.',0777)'); copy( $_FILES[$upload_name]['tmp_name'][$key] , $resize_save_path.$resizeName.'_'.$file_name , 0777 ); chmod( $resize_save_path.$resizeName.'_'.$file_name , 0777 ); } else { //fShowMsg($resize_save_path.$resizeName.'_'.$file_name); } $resized .= $resized ? ','.$resizeName : $resizeName; } } } } if(move_uploaded_file($_FILES[$upload_name]['tmp_name'][$key],$target_file)){ $images_arr[] = $target_file; list($width, $height) = getimagesize($target_file); $sql = " INSERT INTO attachment "; $sql.= " SET a_crt_ip = '".$_SERVER['REMOTE_ADDR']."'"; $sql.= " , a_crt_usr_id = '".$_COOKIE['cookie_uid']."'"; $sql.= " , a_ref_type = '".$_POST['ref_type']."'"; $sql.= " , a_ref_id = '".$_POST['ref_id']."'"; $sql.= " , a_name = '".$file_org_name."'"; $sql.= " , a_upload_id = '".$_POST['upload_id']."'"; $sql.= " , a_path = '".str_replace('../','',$target_file."'"); $sql.= " , a_file_type = '".$file_extension."'"; $sql.= " , a_file_size = '".$file_size."'"; $sql.= " , a_width = '".$width."'"; $sql.= " , a_height = '".$height."'"; $sql.= " , a_resize = '".$resized."'"; // fShowSQL($sql); $clsMySQL->execSQL($sql); $newID = $clsMySQL->getInsertID(); } // ********** ********** ********** ********** ********** // // Show Upload Completed Message Box // echo ''; } } // echo ''; // ********** ********** ********** ********** ********** // // For Debug Check Record Usage // if ( $debug == 2 ) { $sql = " SELECT * FROM attachment ORDER BY a_id DESC LIMIT 10 "; if ( $clsMySQL->execQuery($sql) ) { while( $ary = $clsMySQL->fetchArray() ) { echo '
';
			print_r($ary);
			echo '
'; } } exit(); } // ********** ********** ********** ********** ********** // // For After Submit Reload // // echo ''; ?>