I started to build my upload form from scratch, currently trying to validate an empty string and getting no where any ideas?
<form action="" method="POST" enctype="multipart/form-data" />
<input type="file" name="file_img[]" multiple>
<input type="submit" value="Create directory" name="makeit">
</form>
<?php
error_reporting(E_ALL);
if (!isset($_FILES['file_img'])) {
echo "You kidding me?";
}
else if (isset($_FILES['file_img'])) {
$uploads = $_FILES["file_img"];
if (count($uploads['name'])>0){
foreach ($uploads['name'] as $key => $name) {
if ($uploads['error'][$key] === UPLOAD_ERR_OK) {
$size = $uploads["size"][$key];
$type = $uploads["type"][$key]; // could be bogus!!! Users and browsers lie!!!
$tmp = $uploads["tmp_name"][$key];
$name = $uploads["name"][$key];
if($type != "image/jpeg" && $type != "image/png" && $type != "image/gif")
{
echo "Please upload jpg / png / gif <br />";
}
if($size > 3145728)
{
echo $name . " is too large <br />";
}
else
{
echo "<img src=\"uploads/" . $name . " \" /><br />";
echo $name ;
}
}
}
}
}
?>
Also I have already attempted
if($uploads = "")
{
echo "File needed";
}