Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 使用输入的文本链接instad上传文件_Css_File Upload_Input - Fatal编程技术网

Css 使用输入的文本链接instad上传文件

Css 使用输入的文本链接instad上传文件,css,file-upload,input,Css,File Upload,Input,我知道已经有一些关于这个的帖子了,但是一些帖子的答案似乎引起了一些争议,所以,我想知道是否有一种“万无一失”的方式可以在不使用输入字段的情况下触发文件上传。基本上,我想要做的是有一个带有图标和文本链接的div,当你点击它时,它会触发文件上传。有点像: .upload{ padding: 5px 10px 5px 30px; background: url() center left no-repeat; } <div class="upload">(icon) Click here

我知道已经有一些关于这个的帖子了,但是一些帖子的答案似乎引起了一些争议,所以,我想知道是否有一种“万无一失”的方式可以在不使用输入字段的情况下触发文件上传。基本上,我想要做的是有一个带有图标和文本链接的div,当你点击它时,它会触发文件上传。有点像:

.upload{
padding: 5px 10px 5px 30px;
background: url() center left no-repeat;
}
<div class="upload">(icon) Click here to add a photo</div>
。上传{
填充:5px10px 5px30px;
背景:url()中间偏左不重复;
}
(图标)单击此处添加照片
非常感谢您提供的任何帮助或建议。

请在html中添加以下内容:

<input id="article_file_input" type="file" name="article_picture" style="display: none;">

以及锚定:


单击此处添加文件

答案有什么问题?因为我不想为输入设置样式,我根本不想使用它@用户2546546再次阅读答案。一些解决方案隐藏了输入。谢谢,这正是我想要做的,而且效果很好