cartella privata utente

  • Creatore Discussione Creatore Discussione Imperor
  • Data di inizio Data di inizio

Imperor

Utente Attivo
25 Nov 2010
102
2
18
Roma
www.fcfclean.it
salve e buon pomeriggio sto tentando di rendere visibile la sottocartella con il nome della sessione username ( ogni utente registrato ha una cartella con il suo nome si trova in documenti/ ) ho provato a inserire directori strtolower username alla fine del codice ma mi da due errori 84 86 chiedo aiuto grazie

Codice:
<?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));
                ?>
 
così puoi verificare se ciò che cerchi di fare é corretto

PHP:
// Call the function with the main directory

myVar = "documenti".strtolower($username);

echo "<br />".myVar."<br />";

list_files(myVar);
 
così puoi verificare se ciò che cerchi di fare é corretto

PHP:
// Call the function with the main directory

myVar = "documenti".strtolower($username);

echo "<br />".myVar."<br />";

list_files(myVar);
ciao il tuo code non va :) ecco quello giusto
Codice:
<?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));
                ?>
 

Discussioni simili