티스토리 뷰

업로드

$upfile_path = "./upfile";    // 업로드파일 위치
$upfile_idx = date('Ymdhis').rand(1,9);  // 업로드파일명

if(!is_dir($upfile_path)){       // 업로드 디렉토리 생성
 echo exec("mkdir $upfile_path");
 exec("chmod 707 $upfile_path");
}

if($upfile_size > 0){
 
 $upfile_tmp = $upfile_idx.".".substr($upfile_name,-3);
 exec("cp $upfile $upfile_path/$upfile_tmp");
 exec("chmod 606 $upfile_path/$upfile_tmp");
 if($row->upfile != "") exec("rm -f $upfile_path/*$row->upfile");
 $upfile_sql = " , upfile='$upfile_tmp', upfile_name='$upfile_name' ";
}


다운로드


$file = "./upfile/".$upfile;
$filename = $upfile_name;

if(file_exists($file))
{
   if( strstr($HTTP_USER_AGENT,"MSIE 5.5")){
       header("Content-Type: doesn/matter");
       header("Content-Disposition: filename=$filename");
       header("Content-Transfer-Encoding: binary");
       header("Pragma: no-cache");
       header("Expires: 0");
   }else{
 header("Content-type: application/x-unkown");
 Header("Cache-Control: cache, must-revalidate");
 header("Content-Disposition: attachment; filename=$filename");
 header("Content-Transfer-Encoding: binary");
 header("Pragma: no-cache");
 header("Expires: 0");
   }
  
   if(is_file("$file")){
       $fp = fopen("$file","r");
       if(!fpassthru($fp)) {
           fclose($fp);
       }
   }
 
}else{
   echo "<script>alert('첨부파일이 존재하지 않습니다.');history.go(-1);</script>";
}


파일삭제

 

include "../../dbcon.php";
include "lib.php";

  $upfile_path = "./upfile";    // 업로드파일 위치
 
  $dQuery = "select * from EduList where no='$no'";
  $dResult = mysql_query($dQuery);
  $dArray = mysql_fetch_array($dResult);

  $upfile_name = $dArray[upfile];

  if($upfile_name != "") exec("rm -f $upfile_path/*$upfile_name");
 
  $dQuery = "update EduList set upfile_name='' where no='$no'";
  mysql_query($dQuery);
  삭제후 이동하기

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함