Skip to content
Server
2015.07.13 23:23

파일 업로드 폴더 변경

조회 수 1955 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

게시물에서 등록한 첨부파일이

xe 하위폴더에 저장이 되는데요 

폴더위치를 변경할수 있나요?


modules/file/file.controller.php  에서

function insertFile  와  deleteFile 함수에서

파일업로드 될때의 파일주소를 변경하시면 될거예요

 



file.controller.php에 있는 insertfile함수가 실질적으로 파일첨부를 위한 경로를 지정해주는 함수라고 알고있습니다.

그런데 파일첨부시에 이 함수를 불러오는 곳을 아무리 검색해봐도 나오질 않네요..

제가 확인하고싶은것은

 function insertFile($file_info, $module_srl, $upload_target_srl, $download_count = 0, $manual_insert = false)

 

 

이 $upload_target_srl이 $document_srl 과 연결되는 부분을 알고싶은겁니다!!!ㅠㅠ그래서 검색해보니

 

document.admin.controller.php에서 function moveDocumentModule()함수에

 $inserted_file = $oFileController->insertFile($file_info, $module_srl, $obj->document_srl, $val->download_count, true);

 

여기만 검색되네요..그런데 이 moveDocumentModule함수는 게시글 이동시에 사용하는거 아닌가요?

 

그렇다면 처음 글을 쓸때 insertfile함수를 불러와 document_srl값을 주는 부분은 어디에 있나요!!!!!!!!!!!!!!!!!!!!!!ㅜㅜ

function procFileUpload()

여기를 보세요 



현재 file.controller.php 부분에서 파일첨부 경로를 변경하는걸로 알고 있습니다.

// 이미지인지 기타 파일인지 체크하여 upload path 지정
  if(preg_match("/\.(jpg|jpeg|gif|png)$/i", $file_info['name'])) {
   // direct 파일에 해킹을 의심할 수 있는 확장자가 포함되어 있으면 바로 삭제함
   $file_info['name'] = preg_replace('/\.(php|phtm|html|htm|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
   $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);

   $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));

   // 파일 이름에서 특수문자를 _로 변환
   $_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
   $filename  = $path.$_filename;
   $idx = 1;
   while(file_exists($filename)) {
    $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'+ '.$1',$_filename);
    $idx++;
   }
   $direct_download = 'Y';
  }
  // 동영상파일일 경우 upload path는 videos
  if(preg_match("/\.(wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info['name'])) {
   // direct 파일에 해킹을 의심할 수 있는 확장자가 포함되어 있으면 바로 삭제함
   $file_info['name'] = preg_replace('/\.(php|phtm|html|htm|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
   $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['+ 'name']);

   $path = sprintf("./files/attach/videos/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));

   // 파일 이름에서 특수문자를 _로 변환
   $_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
   $filename  = $path.$_filename;
   echo $filename;
   $idx = 1;
   while(file_exists($filename)) {
    $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'+ '.$idx.'.$1',$_filename);
    $idx++;
   }
   $direct_download = 'Y';
  } else {
   $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
   $filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
   $direct_download = 'N';
  }


위소스를 보시면 아시겠지만.. 동영상 파일들을 따로 분리를 하여 경로를 변경했습니다.

일단 서버 설명을 드리겠습니다.
일단 서버 2대가 있습니다. A = 메인서버 , B = 미디어서버(동영상 파일만) 입니다.
A서버에서 네트워크 드라이브 연결로 B서버 하드를 불러왔습니다.
이렇게 하면 아시는분들은 아시겟지만 A서버에서 B서버 하드를 읽기/쓰기/수정 가능합니다.

일단 파일첨부 부분이 절대경로가 아닌 상대경로인데...
제가 구현하고자 하는건...
동영상파일 첨부할시만 $path를 절대경로인 B서버 경로로 변경하려 합니다.
ffmpeg로 동영상 파일도 변환하게끄름 구현도 해야하는데..
서버가 window 서버라 ffmpeg php 모듈을 설치하기가 어렵더라구요.
그래서 exec,system 명령어로 업로드한 동영상파일을 인코딩 해준다음
기존 업로드한 파일 삭제후 인코딩한 동영상을 등록시키려 합니다.

JSP전공하며.. PHP는 이번에 처음 접하였는데.. 도무지 알수가 없네요 ㅠㅠ..

일단 제일 시급한건 파일첨부 경로를 절대경로로 수정 하는겁니다.
아시는분 계시면 제발.. 알려주시길 바랍니다..ㅠ ㅠ

 // 동영상파일일 경우 upload path는 videos

  if(preg_match("/\.(wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i",
$file_info['name'])) {
   // direct 파일에 해킹을 의심할 수 있는 확장자가 포함되어 있으면 바로 삭제함
   $file_info['name'] = preg_replace('/\.(php|phtm|html|htm|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']);
   $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);

  
   $path = sprintf("절대경로/files/attach/videos/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));

바꿔주시게 되면 다운로드할 경우나 삭제할 경우의 로직도 같은 부분을 확인하셔야 될 수 있습니다.
다시 말씀드리지만.. $path는.. 상대경로이며 실제 $path의 경로는 웹서버 기본루트의 폴더로 시작 됩니다 그래서 위에 방식대로는 웹루투 밖의 절대경로 수정이 불가능 합니다.







로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
32 Server xe 타이틀 게시판 이름 없애기 file 2016.06.28 1803
31 Server mysql 테이블 손상시 #1146 - Table 해결방법 file 2016.07.17 8905
30 Server mysql 16CPU / 16GB My.cnf 1 2016.07.26 2501
29 Server XE 반응형 모바일 메타태그 삽입하기 2016.08.14 3687
28 Server 아파치 mod_cache mod_disk_cache 알아보기 7 2016.08.18 3096
27 Server XE file cache 활용 2016.08.19 1648
26 Server innodb_use_sys_malloc에 따라 The InnoDB memory heap is disabled mysql error 메시지 1 2016.08.23 3794
25 Server innodb_use_sys_malloc to FALSE 2016.08.24 2637
24 Server [php.ini]XE 신디케이션 OpenSSL 오류문구 해결방법 file 2016.08.25 2816
23 Server Apache에 대한 mod_proxy 지원 구성 2016.09.06 1801
22 Server XE Request 줄이기 file 2016.09.07 1937
21 Server XE PC에서 모바일화면 출력방법 file 2016.09.08 2836
20 Server jQuery CDN 2016.09.11 4299
19 Server 윈도우용 MEMcached 설치방법 1 file 2016.09.17 5180
18 Server XpressEngine 최적화 기진곰님의 슈퍼캐시 테스트 file 2016.09.19 5016
17 Server HP XW6600 E5430 SPEC file 2016.11.06 4732
16 Server 슈퍼캐시에서 .htaccess 이부분 제거해야 하나? 2016.11.23 4526
15 Server [mysql] Created tmp disk tables 디스크 쓰기방지 대안 1 2016.11.26 5162
14 Server 램드라이브를 이용한 mysql 번개속도로 개선방법 file 2016.11.27 5238
13 Server Minify로 CSS, JS파일, gzip으로 한꺼번에 압축해서 전송하기 file 2016.11.27 4337
Board Pagination Prev 1 2 3 4 5 Next
/ 5

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소