aprire file pdf in subdirectory
-
salve ho trovato in rete dei codici php per visualizzare sia il nome della cartella e il formato file sottocartella in questo caso è pdf io vorrei che cliccando sul nome pdf si apre per scaricarlo o leggerlo chiedo aiuto grazie
<?PHP // (A) RECURSIVE ITERATOR function riterate ($dir) { $iterator = new DirectoryIterator($dir); $eol = PHP_EOL; foreach ($iterator as $ff) { if ($ff->isDot()) { continue; } if ($ff->isFile()) { echo "{$ff->getFilename()} {$eol}"; } if ($ff->isDir()) { echo "{$ff->getFilename()} - Documento {$eol}"; riterate("{$dir}{$ff->getFilename()}/"); } } } // (B) GO! riterate("documenti/"); ?> -
-
-
-
@giorgiotave ho usato l'intelligenza artificiale
ho fatto qualche modifica inserendo strtolower alla fine del code si può scaricare il file 
<?PHP // Define a function to list files and subfolders function list_files($dir) { // Get an array of files and subfolders $files = scandir($dir); // Loop through the array foreach ($files as $file) { // Skip the current and parent directories if ($file != "." && $file != "..") { // Get the full path of the file or folder $path = $dir . "/" . $file; // Check if it is a file if (is_file($path)) { // Get the file name $name = basename($path); // Encode the file path $url = urlencode($path); // Create a download link echo "Documento: <a href='download.php?file=$url'>$name</a><br>"; } // Check if it is a folder if (is_dir($path)) { // Print the folder name echo "Cartella: <b>$file</b><br>"; // Call the function recursively list_files($path); } } } } // Call the function with the main directory list_files("documenti/".strtolower($username)); ?> -
@giorgiotave ho usato l'intelligenza artificiale
ho fatto qualche modifica inserendo strtolower alla fine del code si può scaricare il file 
<?PHP // Define a function to list files and subfolders function list_files($dir) { // Get an array of files and subfolders $files = scandir($dir); // Loop through the array foreach ($files as $file) { // Skip the current and parent directories if ($file != "." && $file != "..") { // Get the full path of the file or folder $path = $dir . "/" . $file; // Check if it is a file if (is_file($path)) { // Get the file name $name = basename($path); // Encode the file path $url = urlencode($path); // Create a download link echo "Documento: <a href='download.php?file=$url'>$name</a><br>"; } // Check if it is a folder if (is_dir($path)) { // Print the folder name echo "Cartella: <b>$file</b><br>"; // Call the function recursively list_files($path); } } } } // Call the function with the main directory list_files("documenti/".strtolower($username)); ?>@imperor ottimo, grazie!
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi