I can not verify the correctness of the file upload fields, here is my code:
<?php if (isset($_POST['submit'])) { if ($_POST['uploadFile']) { echo "File uploaded"; } else { echo "No file attempted to be uploaded"; } } ?> <form action="" method="post" enctype="multipart/form-data"> <input type="file" name="uploadFile" /> <input type="submit" name="submit" /> </form>
What mistake am I making?
EDIT
I came up with my own solution, maybe not the best, but it works:
if (isset($_POST['submit'])) { $fileUpload = $_FILES['uploadFile'] ['name']; if (strlen($fileUpload) > 0) { echo "File uploaded."; } else { echo "No File attempted to be uploaded."; } }
James source share