I was wondering that each time i refresh my page do I have to somehow clear $_FILES , or why is it echoing back to me that the variable is set and also NOT empty? when i first load, or reload the page is obviously is at least empty by using print_r
<html>
<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</html>
<?php
if(isset($_FILES["file"]) && !empty($_FILES["file"])){
echo 'You have just uploaded '. $_FILES["file"]["name"];
}
?>
!empty()
since empty does not generate an error if checked variable is not set.header()
after postif ($_FILES) { ... }
should work just fine.