2015-04-30 118 views
0

我試圖獲取文件的路徑。嘗試獲取文件的路徑 - 輸入類型=文件 - PHP

有我的代碼:

$htmlcode = '<input type="file" id="fileinput" placeholder="Recherche QR Code" title="Recherche &agrave; partir d\'un fichier .txt" />'; 

$path = ""; 
getTabQrCode($path); 

function getTabQrCode($path){ 
$tab_qr = Array(); 
$index = 0; 
$file_handle = fopen($path, "r"); 

while (!feof($file_handle)) { 

$line_of_text = fgets($file_handle); 
$parts = explode('=', $line_of_text); 

print $parts[0] . $parts[1]. "<BR>"; 
$tab_qr[$index] = $parts[0]; 
$index++; 
} 

$index = 0; 

fclose($file_handle); 

} 

echo $htmlcode; 

我想$路該如何走上傳的文件的路徑的價值... 這可能嗎?

+0

你的意思是訪問者的本地計算機上的文件的路徑?我不認爲這是可能的。考慮與我們分享你的主要目標,你試圖達到的目標。 –

+0

你看過[PHP文檔](http://php.net/manual/en/features.file-upload.php)嗎? –

回答

0

您可以獲得關於與$_FILES陣列

你需要給你的文件輸入一個名稱,但添加enctype屬性的形式,否則沒有文件將被上傳上傳的文件信息。一旦你這樣做,你可以用$_FILES['myFileName']['tmp_name']

見得到的文件的臨時位置:http://php.net/manual/en/reserved.variables.files.php