2012.03.25 12:01


<?
include_once "../common/common.php";

 

 $title=htmlspecialchars($_POST['write_info']);
 $currentTime = date("Y-m-d",time());

 

if(!$title){

?> <script>
 alert("Plz insert title or file");
 location.href="./index.php";
 </script>
<?
  
}

else{

 $FILE=$_FILES['FILE']['name'];
  $cut=explode('.',$FILE);
  $size=sizeof($cut);
  $extension=$cut[$size-1];
  $result=strtolower($extension);

 $addr='javascript:history.back()';

 if ($FILE){
  $SVFILE=date('y-m-d H:i:s').md5($FILE).'.'.$result;
  $img_flag_1=($result=='bmp' or $result=='dib' or $result=='jpg' or $result=='jpeg' or $result=='jpe' or $result=='jfif' or $result=='gif' or $result=='tif' or $result=='tiff' or $result=='png');
  $img_flag_2=($_FILES['FILE']['type']=='image/bmp' or $_FILES['FILE']['type']=='image/dib' or $_FILES['FILE']['type']=='image/jpg' or $_FILES['FILE']['type']=='image/jpeg' or $_FILES['FILE']['type']=='image/pjpeg' or $_FILES['FILE']['type']=='image/jpe' or $_FILES['FILE']['type']=='image/jfif' or $_FILES['FILE']['type']=='image/gif' or $_FILES['FILE']['type']=='image/tif' or $_FILES['FILE']['type']=='image/tiff' or $_FILES['FILE']['type']=='image/png' or $_FILES['FILE']['type']=='image/x-png');
  if ($img_flag_1){
   if ($img_flag_2){
    if($_FILES['FILE']['error']>0){
     $msg='파일을 업로드 할 수 없습니다.';
    }
    if (file_exists('./upload/'.$SVFILE)){
     $msg='파일을 업로드 할 수 없습니다.';
    }
    else{
     move_uploaded_file($_FILES['FILE']['tmp_name'],'./upload/'.$SVFILE);
    }
   }
   else{
    $msg='파일을 업로드 할 수 없습니다.<br>'.$_FILES['FILE']['type'];
   }
  }
  else{
   $msg='파일을 업로드 할 수 없습니다.';
  }
 }
 else{
  $SVFILE='';
  echo("file error");
  echo("<script>
  location.href='./index.php';
  </script>");
 }

 


 $sql="insert into trip (memo,file,date) values ('$title','$SVFILE','$currentTime')";

 mysql_query ($sql);


 //die($sql);


 ?>


 <script>
  location.href="./index.php";
 </script>
 <?

}

 

?>

Posted by k1rha