請問為什么指定地點(diǎn)中會(huì)有擴(kuò)展名?
move_uploaded_file($fileInfo['tmp_name'],$destination): 這樣的意思是把文件$fileInfo['tmp_name']移動(dòng)到文件$destination 中嗎?這里的$destination不應(yīng)該是目錄才對嗎?為什么會(huì)有文件 擴(kuò)展名? $uniName=md5(uniqid(microtime(true),true)).'.'.$ext; //echo?$uniName;exit; $destination=$path.'/'.$uniName; if(@move_uploaded_file($fileInfo['tmp_name'],$destination)){ ???echo?'文件上傳成功'; }else{ ???echo?'文件上傳失敗'; }
2019-09-04
因?yàn)樵谝苿?dòng)之前聲明了一個(gè)
這其中的$path是函數(shù)中可變參數(shù)(老師寫的是第二項(xiàng)),默認(rèn)是./uploads
而$uniName是老師在common中封裝且在doACtion5中用require_once調(diào)用過的函數(shù)getUniName()
所以整體拼裝下來就是【($path)./uploads/($uniName)'一串隨機(jī)生成的字符串,由數(shù)字和字母組成'】。
然后我再來說一下,你的這句代碼少了文件擴(kuò)展名,也就是老師封裝的另外一個(gè)函數(shù) getExt()
你把函數(shù)封裝好了之后,在調(diào)用$ext之前 聲明一個(gè)變量 $ext=getExt($filename).
這樣能懂不?