爲什麼我用php寫的文件上傳程序中 $_FILES['file']['tmp_name'] 的輸出爲空?
代碼如下:
<form action="__URL__/{$btn_ok_act}" method="post" enctype="multipart/form-data" name="upload">
<h3>產品名</h3>
<h3> 產品圖片:</h3>
<br>
<input type="file" name="file" value="瀏覽"/>
<input type="submit" name="submit" value="{$btn_ok_text}"/>
</form>
後臺處理:
public function add() {
header("Content-Type:text/html; charset=utf-8");
//圖片上傳
$type=array("jpg","gif","bmp","jpeg","png"); //圖片的類型
$uploaddir="/ThinkPHP_APP/Public/upload/image/";
echo $_FILES['file']['tmp_name']; //這裏爲什麼輸出爲空,且跳轉到這一步了
echo $_FILES['file']['name']; //這個就可以輸出,怎麼解釋,php.ini中也設置了 upload_tmp_dir ="C:/Windows/Temp/"
$image_file=$_FILES['file']['name'];
$image_tmp=$_FILES['file']['tmp_name'];
$uptype=strtolower(substr(strrchr($image_file,'.'), 1));
if(!in_array($uptype, $type)){
$this->error('您選的圖片不符合類型');
}
$uploadimage=$uploaddir.$image_file;