關於上傳資料的疑惑

來源:互聯網
上載者:User
關於上傳檔案的疑惑
最近在聽php視頻,其中有一個代碼不理解
if (is_uploaded_file($_FILES['upfile']['tmp_name'])){

$upfile=$_FILES["upfile"];

}


主要是取值的問題,比如說upfile我知道是從表單取的值,但是tmp_name我就不知道怎麼取到的值,還請大牛們指教,謝謝!

分享到:


------解決方案--------------------
$_FILES 是一個全域數組,儲存了檔案上傳的一些資訊
第一個參數是表單的 input name,第二個下標可以是 "name", "type", "size", "tmp_name" 或 "error"。就像這樣:
$_FILES["file"]["name"] - 被上傳檔案的名稱
$_FILES["file"]["type"] - 被上傳檔案的類型
$_FILES["file"]["size"] - 被上傳檔案的大小,以位元組計
$_FILES["file"]["tmp_name"] - 儲存在伺服器的檔案的臨時副本的名稱
$_FILES["file"]["error"] - 由檔案上傳導致的錯誤碼

------解決方案--------------------
這要什麼大牛指教啊,連我這個學php不到2個月的都知道了。

看php基礎的教程都有說了。

The entries in $_FILES will be stored with the name of the tag from your
HTML form.Your form element is named userfile, so the array will have the following
contents:
n The value stored in $_FILES[‘userfile’][‘tmp_name’] is the place where the
file has been temporarily stored on the web server.
n The value stored in $_FILES[‘userfile’][‘name’] is the file’s name on the
user’s system.
n The value stored in $_FILES[‘userfile’][‘size’] is the size of the file in bytes.
n The value stored in $_FILES[‘userfile’][‘type’] is the MIME type of the
file―for example, text/plain or image/gif.
n The value stored in $_FILES[‘userfile’][‘error’] will give you any error
codes associated with the file upload.This functionality was added at PHP 4.2.0.
------解決方案--------------------
tmp_name,那是個隨機的檔案名稱
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.