I want to open the image upload file dialogue box if I click the button tag. Is it possible? If so how can I do it in PHP?
while{ echo "<td><button><img src='".$cfet['productimage']."' width='50' height='40'></button></td>"; }
And on the button's click event write the jQuery code like : $('#OpenImgUpload'). click(function(){ $('#imgupload'). trigger('click'); });
Include input type="file"
element on your HTML page and on the click event of your button trigger the click event of input type file element using trigger function of jQuery
The code will look like:
<input type="file" id="imgupload" style="display:none"/> <button id="OpenImgUpload">Image Upload</button>
And on the button's click event write the jQuery code like :
$('#OpenImgUpload').click(function(){ $('#imgupload').trigger('click'); });
This will open File Upload Dialog box on your button click event..
<input type="file" id="imgupload" style="display:none"/> <label for='imgupload'> <button id="OpenImgUpload">Image Upload</button></label>
On click of for= attribute will automatically focus on "file input" and upload dialog box will open
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