The easiest way is to check if there are any files in temporary memory. If you want to get the change event every time user clicks the file input you can trigger it. Show activity on this post. In my case i had to hide submit button while users were selecting images.
length == 0) { alert("Please select a file!") } } We get our input element with document. getElementById() and check the length of the files property, which an input of type file has. If it's empty, we alert the user that no file has been selected.
To check if the input text box is empty using jQuery, you can use the . val() method. It returns the value of a form element and undefined on an empty collection.
You can check if there is a value, and if the image is valid by doing the following: if(empty($_FILES['cover_image']['tmp_name']) || ! is_uploaded_file($_FILES['cover_image']['tmp_name'])) { // Handle no image here... }
And then alert the file name?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With