PHP Multipart上传

Hi I'm trying to upload a PDF file into a server using multi part but it gives me error. what I have done is created a upload page,that the user uploads the PDF file and I session that target file and sent it to the codes below to sent it over to the server am I doing anything wrong below any help would be appreciated. This is the index page.

<form action="upload.php" method="post" enctype="multipart/form-data">
Select file to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload file" name="submit">
</form>  

This is the code that I send the target file to.

<?php
session_start();
$file = $_SESSION ["data"];
?>


<?php

define('MULTIPART_BOUNDARY', '--------------------------'.microtime(true));
$header = 'Content-Type: multipart/form-data; boundary='.MULTIPART_BOUNDARY;
define('file', 'fileToUpload'); 

$filename = $file; 

$content =  "--".MULTIPART_BOUNDARY."
".
        "Content-Disposition: form-data; name=\"".file."\"; 
filename=\"".basename($filename)."\"
";

// add some POST fields to the request too: $_POST['foo'] = 'bar'
$content .= "--".MULTIPART_BOUNDARY."
".
        "Content-Disposition: form-data; name=\"foo\"

".
        "bar
";

// signal end of request (note the trailing "--")
$content .= "--".MULTIPART_BOUNDARY."--
";

$context = stream_context_create(array(
'http' => array(
      'method' => 'POST',
      'header' => $header,
      'content' => $content,
)
));

$result = file_get_contents('//link', false, 
$context);
print_r($result);
?>