<?php

/*****************************************************************
 * Upload a file from client to server
 *****************************************************************/

error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);

$dir = './upload/';

if ($_FILES["filename"]["error"] > 0)
{
    print "Error: " . $_FILES["filename"]["error"] . "<br />";
}
else
{
    echo "Upload File: " . $_FILES["filename"]["name"]     . "<br />";
    echo "Type:        " . $_FILES["filename"]["type"]     . "<br />";
    echo "Size:        " . $_FILES["filename"]["size"]     . "<br />";
    echo "Temporary:   " . $_FILES["filename"]["tmp_name"] . "<br />";

    $tempFile   = $_FILES["filename"]["tmp_name"]; 
    $targetFile = $_FILES["filename"]["name"];
    $dirFile    = $dir . $targetFile; 

    $ok = is_uploaded_file($tempFile);
    if(! $ok)
        die( "File not uploaded - possible attack");

    echo "dir/file: " . realpath($dirFile) . "<br>"; 

    $ok = move_uploaded_file($tempFile, $dirFile);
    if(! $ok)
        echo "Problem with the upload";
    else 
        echo "File Uploaded to:  " . $targetFile;
}
?>

<?php include "../include.php"; ?>              <!-- hyperlink to see the code -->