Question

I have four images to upload. And all these four images are optional in my form.

I tried to make it optional but I could not solve my problem. Please check my code below and let me know any solution for it.

Était-ce utile?

La solution

<?php


if(isset($_FILES))
{
    if(empty($_FILES['testfile']['name']))
    {
        echo 'no';
    }else{
        // do the form validation here
    }
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST" enctype="multipart/form-data">
<input type="file" name="testfile"/>
<input type="submit" value="upload">
</form>

here is some test you can try i hope it helps

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top