0

I'm trying to get the path of a file.

There's my code :

$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;

I want $path to take the value of the path of the file uploaded... Is it possible ?

MrTux
  • 32,350
  • 30
  • 109
  • 146
  • Do you mean the path of the file on the local computer of the visitor? I don't think it's possible. Consider sharing with us your main goal, what you're trying to achieve. – Ofir Baruch Apr 30 '15 at 14:35
  • Have you looked at the [PHP Documentation](http://php.net/manual/en/features.file-upload.php])?! – Pedro Lobito Apr 30 '15 at 14:36

1 Answers1

0

You can get info about an uploaded file with the $_FILES array

You need to give your file input a name and add the enctype attribute to the form though, or else no file will be uploaded. Once you do that, you can get the temporary location of the file with $_FILES['myFileName']['tmp_name']

See: http://php.net/manual/en/reserved.variables.files.php

I wrestled a bear once.
  • 22,983
  • 19
  • 69
  • 116