Adrian Adrian - 7 months ago 10
Javascript Question

Skip file input and use only if is necesary

I have this little form:

<form action="?act=process" method="post" enctype="multipart/form-data">
<input type="file" name="IMG">
<input type="text" name="BG">
<button type="submit">Save</button>
</form>


How can I skip the file input if I want to edit only the text input?
I need both because sometimes i need to channge the image.


  • I need to skip the input after POST submit. Only if the input wasn't changed


Answer

without seeing your PHP code for "after POST submit" I am guessing that you will simply want to code in a conditional check if the IMG input is empty or not before updating your database.

so it might look something like this:

<?php
if(!empty($_POST["IMG"]))
   // update database
Comments