标签中使用该属性。示例您可以尝试运行以下代码来使用accept属性:       FileUploadBox</title"/><meta property="og:local" content="zh"> <meta property="og:title" content="HTML文件输入控件的capture和accept属性无法正常工作-html教程-PHP中文网"> <meta property="og:description" content="使用accept属性在HTML中设置服务器接受的文件类型。只能在<inputtype="file">标签中使用该属性。示例您可以尝试运行以下代码来使用accept属性:<!DOCTYPEhtml><html>  <head>     <title>FileUploadBox</title"> <meta property="og:url" content="https://m.php.cn/zh/faq/603305.html"> <meta property="og:image" content="https://img.php.cn/upload/article/000/000/164/169398150539749.jpg"> <meta property="og:site_name" content="php.cn"> <meta property="og:type" content="website"> <link rel="canonical" href="https://www.php.cn/zh/faq/603305.html"/> <link rel="alternate" hrefLang="zh-cn" href="https://m.php.cn/zh/faq/603305.html" /> <link rel="alternate" hrefLang="en" href="https://m.php.cn/faq/603305.html" /> <link rel="alternate" hrefLang="zh-tw" href="https://m.php.cn/zh-tw/faq/603305.html" /> <link rel="alternate" hrefLang="ja" href="https://m.php.cn/ja/faq/603305.html" /> <link rel="alternate" hrefLang="ko" href="https://m.php.cn/ko/faq/603305.html" /> <link rel="alternate" hrefLang="ms" href="https://m.php.cn/ms/faq/603305.html" /> <link rel="alternate" hrefLang="fr" href="https://m.php.cn/fr/faq/603305.html" /> <link rel="alternate" hrefLang="de" href="https://m.php.cn/de/faq/603305.html" /> <meta charset="utf-8" /><meta name=viewport content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"><meta name="applicable-device" content="mobile" /><link rel="stylesheet" href="/static/css/style.css?4.5.31"><link href="/static/front/mobcss/newphpcommon.css?1.1" type="text/css" rel="stylesheet"/><link href="/static/front/mobcss/swiper.min.css" type="text/css" rel="stylesheet"/><link href="/static/front/mobcss/newphp.css?1.2" type="text/css" rel="stylesheet"/><link href="/static/css/global.css" type="text/css" rel="stylesheet"/><link href="/static/layui/css/layui.css" type="text/css" rel="stylesheet"/><link href="/static/mobcss/mobindex3.css" type="text/css" rel="stylesheet"/><script src="/static/front/mobjs/jquery-1.6.1.min.js"></script><script src="/static/front/mobjs/swiper.min.js"></script><script src="/static/front/mobjs/newphpcommon.js"></script><link rel="canonical" href="https://www.php.cn/zh/faq/603305.html"/> <link rel="alternate" hrefLang="zh-cn" href="https://m.php.cn/zh/faq/603305.html" /> <link rel="alternate" hrefLang="en" href="https://m.php.cn/faq/603305.html" /> <link rel="alternate" hrefLang="zh-tw" href="https://m.php.cn/zh-tw/faq/603305.html" /> <link rel="alternate" hrefLang="ja" href="https://m.php.cn/ja/faq/603305.html" /> <link rel="alternate" hrefLang="ko" href="https://m.php.cn/ko/faq/603305.html" /> <link rel="alternate" hrefLang="ms" href="https://m.php.cn/ms/faq/603305.html" /> <link rel="alternate" hrefLang="fr" href="https://m.php.cn/fr/faq/603305.html" /> <link rel="alternate" hrefLang="de" href="https://m.php.cn/de/faq/603305.html" /> <script> var canshu = { SeeMore:'查看更多', FoldUp:'收起部分', Choice:'语言', wait:'正在加载,请稍候~', LoginFirst:"请先登录", needKeyword:'输入关键词搜索', emailPhoneError:'请输入正确的电话或电子邮件地址', missPwd:'请输入密码', emailError:'请输入您正确的电子邮件地址', VerCode:"请输入验证码", getCode:'发送', pwdError:'密码格式不正确', TwoPassNotMatch:'两个密码不匹配', Bindemail:'绑定邮箱', resetpassword:'重设密码', ConfirmPass:'确认密码', pwdCheck:'请输入6-18个字母或数字', Editinfor: '编辑个人信息', trimContent:'请输入内容', titleCheck:'标题长度应至少为 5 个字', choiceLang:'请选择语言分类', Secondreply:'回复', NetWorkError:'网络错误,请稍后重试!', keywordSearch:'输入关键词搜索', all_lang_string:'zh|en|zh-tw|ja|ko|ms|fr|de', Next:'下一页', Previous:'上一页' }; </script><!-- Google Tag Manager --><script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl; f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-WWVXRJPW'); </script><!-- End Google Tag Manager --><!-- Google tag (gtag.js) --><script async src="https://www.googletagmanager.com/gtag/js?id=G-H42EVCYBJC"></script><script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-H42EVCYBJC'); </script><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5902227090019525" crossorigin="anonymous"></script><!--<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-6267705206177514" crossorigin="anonymous"></script>--><script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"WebSite","url":"https:\/\/m.php.cn\/zh\/","potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/m.php.cn\/zh\/search?word={search_term_string}"},"query-input":"required name=search_term_string"}}</script><meta property="article:author" content="PHPz" /><meta property="article:published_first" content="tutorialspoint.com,https://www.tutorialspoint.com/HTML-file-input-control-with-capture-and-accept-attributes-is-not-working-correctly" /><link rel="stylesheet" href="/static/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css?1"><link rel="stylesheet" href="/static/ueditor/third-party/SyntaxHighlighter/shCoreDefault1.css"><link href="/static/mobcss/newphp.css" type="text/css" rel="stylesheet"/><script src="/static/ueditor/third-party/SyntaxHighlighter/shCore.js"></script><script> var xnb_name = 'Virtual currency'; </script><script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","headline":"HTML文件输入控件的capture和accept属性无法正常工作","description":"使用accept属性在HTML中设置服务器接受的文件类型。只能在<inputtype=\"file\">标签中使用该属性。示例您可以尝试运行以下代码来使用accept属性:<!DOCTYPEhtml><html>  <head>     <title>FileUploadBox<\/title","image":["https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/169398150582933.jpg"],"datePublished":"2023-09-06T14:25:03+8:00","author":{"url":"https:\/\/m.php.cn\/zh\/member\/164.html","name":"PHPz"},"mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/m.php.cn\/zh\/faq\/603305.html"},"url":"https:\/\/m.php.cn\/zh\/faq\/603305.html","articleBody":"<p><img src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/164\/169398150582933.jpg\" alt=\"HTML文件输入控件的capture和accept属性无法正常工作\"><\/p>\n<p>使用<em>accept<\/em>属性在HTML中设置服务器接受的文件类型。只能在<input type=\"file\">标签中使用该属性。<\/p>\n<h2>示例<\/h2>\n<p>您可以尝试运行以下代码来使用accept属性:<\/p><pre class='brush:php;toolbar:false;'><!DOCTYPE html>\n<html>\n   <head>      \n   <title>File Upload Box<\/title>    \n   <\/head>\n   <body>\n      <form>    \n         <input type = \"file\" name = \"fileupload\" accept = \"image\/*\" \/>  \n      <\/form>\n   <\/body>\n<\/html><\/pre><p>capture 属性是一个布尔属性,如果指定,则表示首选直接从设备捕获媒体...。<\/p>\n<p>capture 属性不用于将相机选项包含在对话框,但表示首选从网络摄像头直接捕获。 <\/p>\n<p>下面给出“正确”代码<\/p><pre class='brush:php;toolbar:false;'><input type = \"file\" accept = \"image\/*\"><\/pre>"}</script><script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https:\/\/m.php.cn\/zh\/","name":"首页"}},{"@type":"ListItem","position":2,"item":{"@id":"https:\/\/m.php.cn\/zh\/web-designer.html","name":"web前端"}},{"@type":"ListItem","position":3,"item":{"@id":"https:\/\/m.php.cn\/zh\/div-tutorial.html","name":"html教程"}},{"@type":"ListItem","position":4,"item":{"@id":"https:\/\/m.php.cn\/zh\/faq\/603305.html","name":"HTML文件输入控件的capture和accept属性无法正常工作"}}]}</script></head><body><div class="bodyBg"><link rel="stylesheet" type="text/css" href="/static/csshwm/m_stylehw.css"><header><div class="head"><div class="haed_left"><div class="haed_logo"><a href="https://m.php.cn/zh/" title="PHP中文网" class="haed_logo_a"><img src="/static/imghwm/logo.png" alt="PHP中文网" class="haed_logoimg"></a></div></div><div class="search_div search_div_top2"><input id="key_words" class="search-input" type="text" autocomplete="off" name="keywords" required="required" placeholder="Block,address,transaction,news" value="" onkeydown="if (event.keyCode == 13) searchs('zh')"/><a onclick="searchs('zh')" href="javascript:;" title="搜索"><img onerror="this.onerror=''; this.src='static/imghwm/default1.png'" src="/static/imghwm/find.png" alt="搜索"></a></div><div class="head_right"><button type="button" class="layui-btn layui-btn-primary headerlan headlanmax lan1" id="lan1sp" lay-on="test-offset-r"><img src="/static/imghwm/m_menu.png" alt=""></button><div id="m_menu" class="m_menu" style="display: none;"><div class="m_editormain12main_top"><img src="/static/imghwm/logo.png" alt="logo"><a href="javascript:;" class="m_editormain12main_topi" id="m_editormain12main_topi_sp"><i class="layui-icon layui-icon-close"></i></a></div><div class="layui-panel m_menu_main"><ul class="layui-menu" id="demo-menu"><li class="layui-menu-item-group layui-menu-item-up m_menus" lay-options="{type: 'group'}"><div class="layui-menu-body-title m_menus_title">社区<i class="layui-icon layui-icon-down"></i></div><ul class="m_menusnames"><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/article.html" title="文章">文章</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/faq/zt" title="合集">合集</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/wenda.html" title="问答">问答</a></div></li></ul></li><li class="layui-menu-item-divider"></li><li class="layui-menu-item-group layui-menu-item-up m_menus" lay-options="{type: 'group'}"><div class="layui-menu-body-title m_menus_title">学习<i class="layui-icon layui-icon-down"></i></div><ul class="m_menusnames"><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/course.html" title="课程">课程</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/dic/29.html" title="编程词典">编程词典</a></div></li></ul></li><li class="layui-menu-item-divider"></li><li class="layui-menu-item-group layui-menu-item-up m_menus" lay-options="{type: 'group'}"><div class="layui-menu-body-title m_menus_title">工具库<i class="layui-icon layui-icon-down"></i></div><ul class="m_menusnames"><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/development-tools" title="开发工具">开发工具</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/ai-tools" title="AI工具">AI工具</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/website-source-code" title="网站源码">网站源码</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/php-libraries" title="PHP 库">PHP 库</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/js-special-effects" title="JS特效">JS特效</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/website-materials" title="网站素材">网站素材</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/toolset/extension-plug-ins" title="扩展插件">扩展插件</a></div></li></ul></li><li class="layui-menu-item-divider"></li><li class="layui-menu-item-group layui-menu-item-up m_menus" lay-options="{type: 'group'}"><div class="layui-menu-body-title m_menus_title">休闲<i class="layui-icon layui-icon-down"></i></div><ul class="m_menusnames"><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/game" title="游戏下载">游戏下载</a></div></li><li><div class="layui-menu-body-title m_menus_name"><a href="https://m.php.cn/zh/mobile-game-tutorial/" title="游戏教程">游戏教程</a></div></li></ul></li><li class="layui-menu-item-divider"></li></ul></div><!-- <div class="m_menu_button">--><!-- <a href="javascript:;" title="singup">Create an account</a>--><!-- </div>--><div class="m_menu_button m_menu_button_login"><a href="https://m.php.cn/zh/login" title="Login">Log in</a></div><div class="m_menu_button m_menu_button_lang"><button type="button" class="layui-btn layui-btn-primary headerlan headlanmax lan1" id="lan1" lay-on="page2">简体中文<i class="layui-icon layui-icon-triangle-d"></i></button></div></div><div class="m_menu_lang" id="m_menu_lang" style="display: none;"><div class="m_editormain12main_top"><img src="/static/imghwm/logo.png" alt="logo"><a href="javascript:;" class="m_editormain12main_topi" id="m_editormain12main_topi_lan"><i class="layui-icon layui-icon-close"></i></a></div><div class="m_menu_lang_main"><a href="javascript:setlang('zh-cn');" class="m_menu_lang_mains">简体中文<span>zh-cn</span></a><a href="javascript:setlang('en');" class="m_menu_lang_mains">English<span>en</span></a><a href="javascript:setlang('zh-tw');" class="m_menu_lang_mains">繁体中文<span>zh-tw</span></a><a href="javascript:setlang('ja');" class="m_menu_lang_mains">日本語<span>ja</span></a><a href="javascript:setlang('ko');" class="m_menu_lang_mains">한국어<span>ko</span></a><a href="javascript:setlang('ms');" class="m_menu_lang_mains">Melayu<span>ms</span></a><a href="javascript:setlang('fr');" class="m_menu_lang_mains">Français<span>fr</span></a><a href="javascript:setlang('de');" class="m_menu_lang_mains">Deutsch<span>de</span></a></div></div></div></div></header><script> document.getElementById('lan1sp').addEventListener('click', function (event) { event.preventDefault(); var elements = document.getElementsByClassName('m_menu'); for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'block'; } }); document.getElementById('m_editormain12main_topi_sp').addEventListener('click', function (event) { event.preventDefault(); var elements = document.getElementsByClassName('m_menu'); for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'none'; } }); document.getElementById('lan1').addEventListener('click', function (event) { event.preventDefault(); var elements = document.getElementsByClassName('m_menu_lang'); for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'block'; } }); document.getElementById('m_editormain12main_topi_lan').addEventListener('click', function (event) { event.preventDefault(); var elements = document.getElementsByClassName('m_menu_lang'); for (var i = 0; i < elements.length; i++) { elements[i].style.display = 'none'; } }); </script><div class="bodyMain"><!--所在位置--><div class="nphpSize"><div class="nphpSizeIn"><b></b><p><a href="https://m.php.cn/zh/" title="首页" class="bBlack">首页</a> ><a href="https://m.php.cn/zh/web-designer.html" class="cBlack">web前端</a> ><a href="https://m.php.cn/zh/div-tutorial.html" class="cBlack">html教程</a> >HTML文件输入控件的capture和accept属性无法正常工作</p><!-- <p><a href="https://m.php.cn/zh/article.html" class="cBlack">技术文章</a>  >  <a href="https://m.php.cn/zh/web-designer.html" class="cBlack">web前端</a> > <a href="https://m.php.cn/zh/div-tutorial.html" class="cBlack">html教程</a> > HTML文件输入控件的capture和accept属性无法正常工作</p> --><div class="clear"></div></div></div><div class="nphpQianBox"><div class="nphpQianTitle"><h1>HTML文件输入控件的capture和accept属性无法正常工作</h1><div class="nphpQianTitleIn"><span><img data-src="https://img.php.cn/upload/avatar/000/000/164/59190898474f6485.png" alt="PHPz" class="lazyload" src="/static/front/mobimages/moren/moren.png" /></span><dl><dt><em>PHPz</em><i class='bg2'>转载</i><div class="clear"></div></dt><dd><em>2023-09-06 14:25:03</em><i>1463浏览</i><div class="clear"></div></dd></dl><div class="clear"></div></div></div><div class="nphpQianCont wenda-list"><p><img src="https://img.php.cn/upload/article/000/000/164/169398150582933.jpg" alt="HTML文件输入控件的capture和accept属性无法正常工作"></p> <p>使用<em>accept</em>属性在HTML中设置服务器接受的文件类型。只能在<input type="file">标签中使用该属性。</p> <h2>示例</h2> <p>您可以尝试运行以下代码来使用accept属性:</p><pre class='brush:php;toolbar:false;'><!DOCTYPE html> <html> <head> <title>File Upload Box</title> </head> <body> <form> <input type = "file" name = "fileupload" accept = "image/*" /> </form> </body> </html></pre><p>capture 属性是一个布尔属性,如果指定,则表示首选直接从设备捕获媒体...。</p> <p>capture 属性不用于将相机选项包含在对话框,但表示首选从网络摄像头直接捕获。 </p> <p>下面给出“正确”代码</p><pre class='brush:php;toolbar:false;'><input type = "file" accept = "image/*"></pre><p>以上是HTML文件输入控件的capture和accept属性无法正常工作的详细内容。更多信息请关注PHP中文网其他相关文章!</p></div><div class="nphpQianMsg"><a href="javascript:void(0);">html</a> <a href="javascript:void(0);">input</a><div class="clear"></div></div><div class="nphpQianSheng"><span>声明:</span><div>本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除</div></div></div><div class="nphpSytBox"><span>上一篇:<a class="dBlack" title="我们如何使用分割标签来为HTML元素设置样式?" href="https://m.php.cn/zh/faq/603263.html">我们如何使用分割标签来为HTML元素设置样式?</a></span><span>下一篇:<a class="dBlack" title="如何在HTML中创建带有图像符号的无序列表?" href="https://m.php.cn/zh/faq/603377.html">如何在HTML中创建带有图像符号的无序列表?</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>相关文章</h2><em><a href="https://m.php.cn/zh/article.html" class="bBlack"><i>查看更多</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="https://m.php.cn/zh/faq/348757.html" title="Html小知识总结" class="aBlack">Html小知识总结</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/zh/faq/348804.html" title="如何快速学习HTML" class="aBlack">如何快速学习HTML</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/zh/faq/348873.html" title="html xhtml xml的区别" class="aBlack">html xhtml xml的区别</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/zh/faq/348884.html" title="src与href属性的区别" class="aBlack">src与href属性的区别</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/zh/faq/348902.html" title="关于HTML5和CSS替换使用" class="aBlack">关于HTML5和CSS替换使用</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>公益在线PHP培训,帮助PHP学习者快速成长!</p></div><div class="footermid"><a href="https://m.php.cn/zh/about/us.html">关于我们</a><a href="https://m.php.cn/zh/about/disclaimer.html">免责声明</a><a href="https://m.php.cn/zh/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body><!-- Matomo --><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '9']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!-- End Matomo Code --></html>