功能二:上傳檔案功能的基本實現

來源:互聯網
上載者:User

標籤:php檔案   服務   基本   action   一個   檔案   type   cti   舉例   

  使用表單實現檔案上傳:

<form action="upload_file.php" method="post" enctype="multipart/form-data">    <label for="file">檔案名稱:</label>    <input type="file" name="file" id="file"><br>    <input type="submit" name="submit" value="提交"></form>

注意:

  • <form> 標籤的 enctype 屬性規定了在提交表單時要使用哪種內容類型。在表單需要位元據時,比如檔案內容,請使用 "multipart/form-data"。
  • <input> 標籤的 type="file" 屬性規定了應該把輸入作為檔案來處理。舉例來說,當在瀏覽器中預覽時,會看到輸入框旁邊有一個瀏覽按鈕。

    在網頁上點擊“提交”提交按鈕後,可在upload_file.php檔案對檔案實現一些操作,如:
  • $_FILES["file"]["name"] - 上傳檔案的名稱
  • $_FILES["file"]["type"] - 上傳檔案的類型
  • $_FILES["file"]["size"] - 上傳檔案的大小,以位元組計
  • $_FILES["file"]["tmp_name"] - 儲存在伺服器的檔案的臨時副本的名稱
  • $_FILES["file"]["error"] - 由檔案上傳導致的錯誤碼









功能二:上傳檔案功能的基本實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.