2013-07-03 2 views
0

그래서 내가 로컬 호스트 웹 사이트에 글꼴을하고있어, 나는 사용자가 카트에 여러 개의 파일을 선택할 수 있도록 관리, 그들은 같은 폴더에서 예를 들어 C를 다운로드 할 수 있습니다 :/fonts/a 또는 C :/fonts/b하지만 a와 b의 파일이있는 경우 다운로드 할 수 없습니다.PHP는 우편 번호 및 여러 폴더에서 파일을 다운로드

이렇게 할 수 있습니까? A와 B 모두에서 다운로드 선택한 파일처럼

다음

  <?php 
      include 'dbfunctions.php'; 

      if (!$link) { 
       die(mysqli_error($link)); 
      } 
      $sql="SELECT id, Font_Name, Font_Family 
         FROM font"; 
      $result = mysqli_query($link, $sql) or die(mysqli_error($link)); 

      while($row = mysqli_fetch_array($result)){ 

      $Font_Family = $row['Font_Family']; 
      $a = file_get_contents('./a.txt'); 
      $file_dir = file_get_contents('./font_path.ini'); 

      $path = $file_dir.$Font_Family.$a; 

      $error = ""; //error holder 
      if(isset($_POST['createpdf'])) 
      { 
      $Font_Family = $_POST['Font_Family']; 
      } 
      $file_folder = $path;// folder to load files 
      if(extension_loaded('zip')) 
      { 
      // Checking ZIP extension is available 
      if(isset($_POST['files']) and count($_POST['files']) > 0) 
      { 

      // Checking files are selected 
      $zip = new ZipArchive(); // Load zip library 
      $zip_name = time().".zip"; // Zip name 
      if($zip->open($zip_name, ZIPARCHIVE::CREATE)!==TRUE) 
      { 
      // Opening zip file to load files 
      $error .= "* Sorry ZIP creation failed at this time"; 
      } 
      foreach($_POST['files'] as $file) 
      { 
      $zip->addFile($file_folder.$file,pathinfo($file,PATHINFO_BASENAME)); 
      readfile($path); 

      } 
      $zip->close(); 
      if(file_exists($zip_name)) 
      { 
      // push to download the zip 
      header('Content-type: application/zip'); 
      header('Content-Disposition: attachment; filename="'.$zip_name.'"'); 
      readfile($zip_name); 
      // remove zip file is exists in temp path 
      unlink($zip_name); 
      } 

      } 
      else 
      $error .= "* Please select file to zip "; 
      } 
      else 
      $error .= "* You dont have ZIP extension"; 
      } 

      ?> 

fontpath.ini가 c download.php 내 코드입니다 : \ 글꼴
\ A는 그냥 \ PHP는 나에게 문제가 때를 제공하기 때문에
그래서 경로는 C처럼 \ \ 글꼴 : 그냥 \
FONT_FAMILY은 C 안에 다른 폴더 이름 쓰기에 관계없이 디렉토리의,

+0

PHP는 무슨 문제를 줬어? – DevZer0

+0

그들은 단지 '로 취급하고 그것을 닫습니다. – Ren

답변

0

당신은 각 글꼴이 걸릴 수 있습니다 \ \ 글꼴 (여기 중 폴더 이름) 임시 디렉토리에 복사하십시오. like, C:/fonts/temp/cartID/. 그런 다음 해당 글꼴 디렉토리 (/ fonts/a 및 fonts/b 중 일부)를 압축하여 다운로드 할 수 있습니다. 그런 다음 가비지 수집, 즉 temp cartID 디렉토리를 삭제해야합니다.

그냥 내 2 ¢

+0

어떻게하면됩니까? 인터넷에 예제가 있습니까? 나는 그것을 실제로 발견 할 수 없다. 그게 상사가 제안하는 것이기 때문이야 – Ren

+0

나는있을 것이라고 확신합니다. Windows에 익숙하지 않지만 PHP 코드에서 linux를 사용하는 예가 있습니다. exec ("cp /fonts/a/font_name.ttf /fonts/temp/845/font_name.ttf"); exec ("cp /fonts/b/font2.ttf /fonts/temp/845/font2.ttf"); ... 우편 번호를 미리 만들고 다운로드하십시오. exec ("rm/fonts/temp/845 /"); – dmayo

+0

이 페이지를 체크 아웃하십시오 : http://php.net/manual/en/function.copy.php 거기에 몇 가지 windows 명령, _and_ 네이티브 부팅 PHP 함수 (나는 방금 새로운 것을 배웠습니다!). – dmayo

관련 문제