<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                今天先來介紹文件下載的第一種方法:通過超鏈接實現文件下載。代碼如下: 1、先執行文件上傳: <!--upload.html--> <form method="post" action="upload.php" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input type="file" name="file[]" /> <input type="file" name="file[]" /> <input type="file" name="file[]" /> <input type="submit" name="sub" value="上傳" /> </form> 2、文件上傳到服務器之后,將上傳的文件相關信息存到數據庫當中: /*upload.php*/ if($_POST['sub']=='上傳'){ echo '<pre>'; print_r($_FILES); function delEmpty($v){ return $v!=''; } $newUpName = array_filter($_FILES['file']['name'],'delEmpty'); $dirName = 'upload/'.date('ymd'); if(!is_dir($dirName)){ mkdir($dirName,0777,1); } foreach($newUpName as $k=>$v){ if(is_uploaded_file($_FILES['file']['tmp_name'][$k])){ $newPath = $dirName.'/'.time().$_FILES['file']['name'][$k]; if(move_uploaded_file($_FILES['file']['tmp_name'][$k],$newPath)){ $pdo = new PDO('mysql:host=localhost;dbname=upload','upload','upload'); $sql = 'insert into file set fname="'.$_FILES['file']['name'][$k].'",fpath="'.$newPath.'",fsize="'.filesize($newPath).'"'; $pdo->query($sql); }else{ echo '<script type="text/javascript"> alert("上傳失敗"); history.go(-1); </script>'; } }else{ echo '<script type="text/javascript"> alert("不是通過http post方法上傳的"); history.go(-1); </script>'; } } } 3、在file_list頁面中查找存儲到數據庫中的文件信息,并顯示,點擊下載按鈕,即可下載對應的文件: /*file_list.php*/ <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>上傳文件</title> </head> <body> <table cellpadding="0" cellspacing="0" border="1"> <thead> <tr> <td>文件名</td> <td>文件路徑</td> <td>文件大小</td> </tr> </thead> <tbody> <?php $pdo = new PDO('mysql:host=localhost;dbname=upload','upload','upload'); $sql = 'select * from file'; $result = $pdo->query($sql); $res = $result->fetchAll(PDO::FETCH_ASSOC); foreach($res as $k=>$v){ echo ' <tr> <td>'.$v['fname'].'</td> <td><a href="'.$v['fpath'].'">下載</a></td> <td>'.$v['fsize'].'</td> </tr> '; } ?> </tbody> </table> </body> </html> 這里需要新建一個upload數據庫,然后建一張file數據表,截圖如下: ![](https://box.kancloud.cn/c26209c6f9fa9c360dd63d838fe49a35_636x348.jpg =600x400)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看