I need to upload a file into the server using PHP and an HTML form.
I used the w3school's example: PHP 5 File Upload which is very helpful and helped me a lot.
Of course I need to adapt that code in order to solve my problem, so this is the situation:
1) the HTML form is placed into fileform.php:
<!-- fileform.php -->
<form action="upload.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>
2) this is my upload.php:
<?php
/* upload.php */
set_time_limit(0);
$targetDir = "/path/to/upload/dir";
$targetFile = $targetDir . basename($_FILES["fileToUpload"]["name"]);
$upload = 1;
$fileType = pathinfo($targetFile, PATHINFO_EXTENSION);
if(isset($_POST["submit"]))
{
    /* Check file size */
    if($_FILES["fileToUpload"]["size"] > 50000000000)
    {
        echo "Sorry, your file is too large.";
        $upload = 0;
        ob_end_flush();
        include("fileform.php");
    }
    /* Allow certain file formats */
    if($fileType != "data" )
    {
        echo "Sorry, non valid filetype.";
        $upload = 0;
        ob_end_flush();
        include("fileform.php");
    }
    /* Check if $uploadOk is set to 0 by an error */
    if($upload == 0)
    {
        echo "Sorry, your file was not uploaded.";
        ob_end_flush();
        include("fileform.php");
    } 
    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.";
        }
        ob_end_flush();
        include("fileform.php");
    }
}
I can upload correctly the file, but I cannot reload correctly the PHP page. It only appears a page with white backgroung showing:
The file file.data has been uploaded.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/upload.php:40) in /var/www/login.php on line 4
with some icons of the PHP page...
I am quiet sure I am doing something wrong into the upload.php file but I don't know what exactly is wrong and so how to fix it.
How do I have to change my code in order to reload the PHP page correctly?
Thank you in advance for your help.
 
     
     
     
     
    