如何使用jQuery更改为Bootstrap中的文件名更改。

发布于 2025-02-12 02:25:31 字数 471 浏览 1 评论 0原文

我试图将上传文件中选择的文件设置为文件名。如何将未选择的文件设置为文件名。 我尝试过的是:

<input class="form-control" id="imgInp" type="file" accept=".png,.jpg,.jpeg" name="img" required> 

在表单的负载下,我试图将选择的文件的值设置为文件名

$('#imgInp').val('abcd.jpg');

“

如何更改文件输入中不选择文件?

I am trying to set no file chosen in upload file to a filename . How to set no file chosen to a file name.
What I have tried is:

<input class="form-control" id="imgInp" type="file" accept=".png,.jpg,.jpeg" name="img" required> 

On load of a form , I am trying to set value of no file chosen to a filename

$('#imgInp').val('abcd.jpg');

Output

How to change no file chosen in file input?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十雾 2025-02-19 02:25:31

简单解决方案:

添加占位符

<input class="form-control" id="imgInp" placeholder="no file chosen" type="file" accept=".png,.jpg,.jpeg" name="img" required> 

Easy Solution:

Add placeholder

<input class="form-control" id="imgInp" placeholder="no file chosen" type="file" accept=".png,.jpg,.jpeg" name="img" required> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文