안효원 안효원 2021-07-13
다운로드 페이지 오류 해결
@166555dd71360692b805ed886e41673e56c9cf8b
 
.idea/php.xml (added)
+++ .idea/php.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
+</project>(No newline at end of file)
config/download.php
--- config/download.php
+++ config/download.php
@@ -1,31 +1,37 @@
 <?php
-include("db.config.php");
+    include("db.config.php");
+    ini_set("display_errors",0);
 
-$filepath = "/home/hw/www/download/";
-$file = $_GET['file'];
-$down = $filepath.$file;
-$filesize = filesize($down);
+    $filepath = "/home/hw/www/download/";
+    $file = $_GET['file'];
+    $down = $filepath.$file;
+    $filesize = filesize($down);
 
-//파일 다운로드
-if(file_exists($down)){        //파일의 존재여부 확인
-    header("Content-Type:application/octet-stream");
-    header("Content-Disposition:attachment;filename=$file");  //다운로드 대화상자 띄움
-    header("Content-Transfer-Encoding:binary");               //인코딩 형식 지정정
-    header("Content-Length:".filesize($filepath.$file));       //업로드한 파일 크기
-    header("Cache-Control:cache,must-revalidate");            //캐싱 방지
-    header("Pragma:no-cache");                                //캐싱 방지
-    header("Expires:0");                                      //캐싱 방지
 
-    if(is_file($down)){            //파일의 존재여부 확인
-        $openFile = fopen($down,"r");    //파일 열기 , r : 읽기전용
-        while(!feof($openFile)){         //파일 내용끝날때 까지
-            $buf = fread($openFile,8192);//파일 읽기, 8192byte
-            $read = strlen($buf);
-            print($buf);
-            flush();               //출력버퍼를 비움
+    //파일 다운로드
+    if(file_exists($down)){        //파일의 존재여부 확인
+        header("Content-Type:application/octet-stream");
+        header("Content-Disposition:attachment;filename=$file");  //다운로드 대화상자 띄움
+        header("Content-Transfer-Encoding:binary");               //인코딩 형식 지정정
+        header("Content-Length:".filesize($filepath.$file));      //업로드한 파일 크기
+        header("Cache-Control:cache,must-revalidate");            //캐싱 방지
+        header("Pragma:public");                                  //캐싱 방지
+        header("Expires:0");                                      //캐싱 방지
+
+        if(is_file($down)){            //파일의 존재여부 확인
+            $openFile = fopen($down,"r");    //파일 열기 , r : 읽기전용
+            while(!feof($openFile)){         //파일 내용끝날때 까지
+                $buf = fread($openFile,8192);//파일 읽기, 8192byte
+                $read = strlen($buf);
+                print($buf);
+                flush();               //출력버퍼를 비움
+            }
+            fclose($openFile);               //파일 닫기
         }
-        fclose($openFile);               //파일 닫기
-    }
-} else{?>
-    <script>alert("존재하지 않는 파일입니다.")</script>
-<?php}
(No newline at end of file)
+        else{
+            echo "None file";
+        }
+    } else{
+        echo "<script>alert('존재하지 않는 파일입니다.')</script>";
+        echo "<meta http-equiv='refresh' content='0.1; url=../view.php?whereValue=". $_GET['whereValue']."&option=".$_GET['option']."&searchText=".$_GET['text']."'>";
+    }
(No newline at end of file)
view.php
--- view.php
+++ view.php
@@ -40,7 +40,7 @@
         .pwText {width: 100px;}
         #answerPrint {border-bottom: white solid 10px; width: 100%;}
         #changedContent {width: 60%; height: 50px; display: inline;}
-        #answerTitle {width: 100%; text-align: center; font-weight: bolder; font-size: larger; border-top: white solid 10px;}
+        #answerTitle {width: 100%; text-align: center; font-weight: bolder; border-top: white solid 10px;}
         .replyForm {text-align: right; padding-right: 25%;}
         .replyBtn {font-weight: bolder; background-color: tomato; border-style: none; color: white; height: 25px; width: 45px;}
         .replyBtn:hover {background-color: black;}
@@ -77,7 +77,7 @@
         <p id="contents"><?php echo $row['contents']; ?></p>
     </div>
     <div id="file">
-        <br>첨부파일 : <a href="config/download.php?file=<?php echo $row['file']?>"><?php echo $row['file'];?></a>
+        <br>첨부파일 : <a href="config/download.php?file=<?php echo $row['file']?>&whereValue=<?php echo $row['num']?>&option=<?php echo $_GET['option']?>&searchText=<?php echo $text?>"><?php echo $row['file'];?></a>
     </div>
     <div id="btnControl">
         <button class="btnS" id="btnUpdate" onclick="location.href='updateWrite.php?whereValue=<?php echo $row['num'];?>&option=<?php echo $_GET['option']?>&searchText=<?php echo $text?>'">수정</button>
@@ -94,7 +94,7 @@
             <input class="btnS" type="submit" value="확인">
         </form>
     </div>
-    <h2><span id="answerTitle">댓글</span></h2>
+    <h2 id="answerTitle">댓글</h2>
     <div id="answerSelect">
         <?php
         if(!$result){
Add a comment
List