Buongiorno sto provato a caricare un doc pdf in ogni sottocartella ma mi da errore riga 83  la sottocartella si tova in documenti/cartella nome utente non riesco a capire perchè il file lo mette solo in documenti/ e no nella sotto cartella selezionata posto il codice
	
	
	
		
				
			
		Codice:
	
	 <?php
                // Check if the form was submitted
                if($_SERVER["REQUEST_METHOD"] == "POST"){
                    // Check if file was uploaded without errors
                    if(isset($_FILES["file"]) && $_FILES["file"]["error"] == 0){
                        // Get the subdirectory from the select element
                        $subdir = $_POST["subdir"];
                        // Set the destination path and filename
                        $target_dir = "documenti/" . $subdir . "documenti/";
                        $target_file = $target_dir . basename($_FILES["file"]["name"]);
                        // Move the uploaded file to the destination
                        if(move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)){
                            echo "The file ". basename( $_FILES["file"]["name"]). " has been uploaded to " . $subdir . ".";
                        } else{
                            echo "Sorry, there was an error uploading your file.";
                        }
                    } else{
                        echo "Error: " . $_FILES["file"]["error"];
                    }
                }
                ?>
                    <h6>carica documento</h6>
                 <?php
                    $subdir = glob("documenti/*");
                    ?>
                    <form action="admin.php" method="post" enctype="multipart/form-data">
                      <label for="select-cartella">Scegli la cartella di destinazione</label>
                      <select name="subdir" id="subdir">
                    <?php foreach($subdir as $subdir): ?>
                        <option value="<?= htmlspecialchars($subdir) ?>"><?= htmlspecialchars(basename($subdir)) ?></option>
                    <?php endforeach ?>
                      </select>
                     <input type="file" name="file" id="file">
                     <input type="submit" value="Upload File" name="submit">
                    </form>
	
			
				Ultima modifica: