i need to change inputfile image value with js or jquery. I tried but i couldn't. You can see my html code, js code that how i read value of inputfile.
<input type="file" style="margin:auto" class="form-control form-control-file"
id="uploadImg" name="uploadImg" accept="image/*" required="">
let urlImage = "/path/Image"
$("#uploadImg").val(urlImage); // is it true?
When i try like,
$("#uploadImg").val()
//"C:\fakepath\wp2429207-evil-morty-wallpapers.png"
When i try this, i take this error.
$("#uploadImg").val("C:\fakepath\wp2429207-evil-morty-wallpapers.png")
Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string. at HTMLInputElement. (https://code.jquery.com/jquery-3.2.0.min.js:4:3606) at Function.each (https://code.jquery.com/jquery-3.2.0.min.js:2:2715) at r.fn.init.each (https://code.jquery.com/jquery-3.2.0.min.js:2:1003) at r.fn.init.val (https://code.jquery.com/jquery-3.2.0.min.js:4:3301) at :1:17