why doesn't the unset function remove $_FILES contents or empty it after uploading a file . how can I empty my $FILES variable after uploading a file .
<html>
<head>
<title>Files Upload</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="pdf" id="pdf"><br>
<input type="submit" name="sumbit" value="upload">
</form>
</body>
</html>
<?php
unset($GLOBALS['$_FILES']);
echo "<pre>";
var_dump($_FILES);
echo "</pre>";
?>
The Output is :
array(1) {
["pdf"]=>
array(5) {
["name"]=>
string(19) "Courses Degrees.pdf"
["type"]=>
string(15) "application/pdf"
["tmp_name"]=>
string(24) "C:\xampp\tmp\php6BBD.tmp"
["error"]=>
int(0)
["size"]=>
int(624129)
}
}
You have to specify the key of the variable
unset($_FILES['key']);
Your key is probably "pdf" when looking at your output
unset($_FILES['pdf']);