<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 前端頁面的表單 **** ~~~ <form action="{:url('index/index')}" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="200"> <input type="file" name="up"> <input type="submit" value="提交"> </form> ~~~ 注意:form的屬性:enctype="multipart/form-data" 限制上傳文件的大小name="MAX_FILE_SIZE" value="200";必須在 type="file"的前面 ***** # 配置文件 ***** 修改PHP對應版本的php.ini配置文件可以定制上傳機制 | 配置 | 說明 | | --- | --- | | file_uploads | 是否允許上傳文件,On開啟 Off禁止上傳 | | upload_tmp_dir | 文件上傳過程中臨時保存的目錄,默認關閉狀態 | | upload_max_filesize | 允許上傳的最大文件大小(單個文件),可以使用K、M、G單位如2M| | post_max_size | PHP將接受的最大post數據大小,包括上傳文件、表單數據。所以post_max_size要大于upload_max_filesize | | max_file_uploads | 單個請求時,允許上傳的最大文件數量| # 超全局數組 ***** 上傳的文件保存在 $_FILES 超全局數組中,具體參數說明如下: | 選項 | 說明 | | --- | --- | | tmp_name | 臨時文件名 | | name | 上傳的原始文件名 | | type | 文件MIME類型 | | error | 錯誤編碼 | | size | 文件大小,單位字節 | 提交到后臺后看云使用 $_FILES 獲取到提交文件的數據如下: ~~~ ["up"] => array(5) { ["name"] => string(13) "公眾號.jpg" ["type"] => string(10) "image/jpeg" ["tmp_name"] => string(22) "C:\Windows\phpEB80.tmp" ["error"] => int(0) ["size"] => int(163380) } ~~~ # 錯誤說明 ***** 上傳出錯會在 $_FILES['error'] 選項中體現,具體錯誤如下: | 錯誤 | 錯誤碼 |說明| | --- | --- | --- | | UPLOAD_ERR_OK | 0 | 沒有錯誤發送 | | UPLOAD_ERR_INI_SIZE | 1 | 上傳的文件超過了 php.ini中 upload_max_filesize選項限制的值 | | UPLOAD_ERR_FORM_SIZE | 2 | 上傳文件的大小超過了HTML表單中MAX_FILE_SIZE選項指定的值 | | UPLOAD_ERR_PARTIAL | 3 | 文件只有部分被上傳,上傳中斷 | | UPLOAD_ERR_NO_FILE | 4 | 沒有文件被上傳 | | UPLOAD_ERR_NO_TMP_DIR | 6 | 找不到臨時文件夾 | | UPLOAD_ERR_CANT_WRITE | 7 | 文件寫入失敗 | # 上傳安全 ***** 上傳通過 is_uolpaded_file 和 move_uploaded_file完成,函數會檢測文件是否是合法的上傳文件,以保證安全 ~~~ if ($_FILES['up']['error'] > 0) { die('上傳失敗,請檢查文件類型或大小'); } $uploadFile = 'uploads/' . time() . '.' .pathinfo($_FILES['up']['name'])['extension']; if (is_uploaded_file($_FILES['up']['tmp_name'])) { if (move_uploaded_file($_FILES['up']['tmp_name'],$uploadFile)) { die('上傳成功:'.$uploadFile); } } die('上傳錯誤'); ~~~ # 處理類 ***** 下面是支持單文件、多文件上傳的處理類 ## **前臺代碼** ~~~ <form action="controller.php" method="post" enctype="multipart/form-data"> <input type="file" name="up"> <input type="file" name="image[]"> <input type="file" name="image[]"> <button class="btn">提交上傳</button> </form> ~~~
                  <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>

                              哎呀哎呀视频在线观看