본문 바로가기

Web Program/Php Lecture21

헤더에 이미지 날리기 if(file_exists($file_full_path) == false) { header ("HTTP/1.0 404 Not Found"); exit; } //echo $file_full_path; //exit; header("Content-type: image/jpeg"); header("Content-Disposition: inline; filename=$file_full_path"); header("Content-length:" . filesize("$file_full_path")); readfile("$file_full_path"); exit; 2008. 9. 8.
fgetcsv 를 이용한 csv 파일 읽기 1. 일반적 방법 /** * Based on an example by ramdac at ramdac dot org * Returns a multi-dimensional array from a CSV file optionally using the * first row as a header to create the underlying data as associative arrays. * @param string $file Filepath including filename * @param bool $head Use first row as header. * @param string $delim Specify a delimiter other than a comma. * @param int $len Line len.. 2008. 9. 8.
text 파일 db 에 입력하기 include "db.php";     $data=file("mbr_tb.txt");     foreach($data as $i =>$line)     {         $update_data=explode(",",$line);         echo "이름 $update_data[0] 아이디 $update_data[1] 비밀번호 $update_data[2] 주민번호 $update_data[3]-$update_data[4]";         $query='update 업데이트테이블 set 아이디="'.$update_data[1].'", 비밀번호="'.$update_data[2].'" where 이름 = "'.$update_data[0].'" and 주민등록번호 ="'.trim($update_data[3].. 2008. 9. 8.
파일 다운로드2 (헤더 이용) /*down.php 를 새로운 창으로 띄움 (popup 등) 설정 파일 읽어들임 dbconnection 등include "../lib/setup.php"; 다운로드 회수 증가나 다른부분 넣음 아래부터 다운로드 부분 file1 = 업로드시 올린 파일명 (test.zip) sfile1 = 실제 서버에 들어가 있는 파일저장 장소 (directory 포함 - /home/test/www/data/test.zip)*/$dn = "1"; // 1 이면 다운 0 이면 브라우져가 인식하면 화면에 출력$dn_yn = ($dn) ? "attachment" : "inline";$bin_txt = "1";$bin_txt = ($bin_txt) ? "r" : "rb";$file   = $row[sfile1]; # 서버에 저장된 .. 2008. 9. 8.