无法获取输入类型的值=“文件”? [英] Can't get value of input type="file"?

查看:97
本文介绍了无法获取输入类型的值=“文件”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< input type =fileid =uploadPicturevalue =123>



当我使用时: alert($(#uploadPicture)。val());



它提醒一个空白的对话框。

解决方案

你可以阅读它,但你不能设置<强>它。 value =123将被忽略,所以直到您点击它并选择一个文件才会有值。



即使这样,该值可能会被像$ c:\fakepath\ 这样的东西,以保持用户的文件系统的详细信息是私有的。 >

I have a <input type="file" id="uploadPicture" value="123">

When I'm using: alert($("#uploadPicture").val());

It alerts an empty dialog.

解决方案

You can read it, but you can't set it. value="123" will be ignored, so it won't have a value until you click on it and pick a file.

Even then, the value will likely be mangled with something like c:\fakepath\ to keep the details of the user's filesystem private.

这篇关于无法获取输入类型的值=“文件”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆