Grazie per la risposta.
Tuttavia continuo a non capire perché non ricarica la pagina anche se io la includo.
Ho messo tutto il codice all'interno dello stesso file PHP, eliminando le istruzioni:
Codice PHP:
ob_start();
session_start();
ob_end_flush();
pagina.php
codice:
if(isset($_POST["submit"]))
{
$targetDir = "/path/to/upload/dir";
$targetFile = $targetDir . basename($_FILES["fileToUpload"]["name"]);
$upload = 1;
$fileType = pathinfo($targetFile, PATHINFO_EXTENSION);
/* Check file size */
if($_FILES["fileToUpload"]["size"] > 500000)
{
echo "Sorry, your file is too large.";
$upload = 0;
}
/* Allow certain file formats */
if($fileType != "data" )
{
echo "Sorry, non valid filetype.";
$upload = 0;
}
/* Check if $uploadOk is set to 0 by an error */
if($upload == 0)
{
echo "Sorry, your file was not uploaded.";
}
else
{
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $targetFile))
{
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
}
else
{
echo "Sorry, there was an error uploading your file.";
}
}
}
<form action="pagina.php" method="post" enctype="multipart/form-data">
<h3>Upload a file:</h3>
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload" name="submit">
</form>
Ma il comportamento è lo stesso...