How do I do it? These don't work:
if(empty($_FILES)){
echo "there is no file uploaded";
exit;
} else {
echo "there is file";
}
if(sizeof($_FILES)!=0){
echo "there is file";
} else {
echo "there is no file";
}
How do I do it? These don't work:
if(empty($_FILES)){
echo "there is no file uploaded";
exit;
} else {
echo "there is file";
}
if(sizeof($_FILES)!=0){
echo "there is file";
} else {
echo "there is no file";
}
Try
Sample :
<?php
if (isset ( $_FILES ['image'] )) {
if ($_FILES ["image"] ["error"] == UPLOAD_ERR_OK) {
echo "File Was Uploaded AND OK";
} else {
echo "File Was Uploaded but BAD";
}
} else {
echo "No File Uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<label for="file">Filename 1:</label> <input type="file" name="image"
id="file" /> <br /> <input type="submit" name="submit" value="Submit" />
</form>
You can see more examples here http://php.net/manual/en/function.move-uploaded-file.php
From: http://php.net/manual/en/reserved.variables.files.php
"If $_FILES is empty ... try adding enctype="multipart/form-data"
to the form tag and make sure you have file uploads turned on."
you can use is_array($_FILES) to check if it contains files info in array format or not