Andy_L20066, маску не получится задать, через скрипт можно выводить сообщение пользователю
| Код | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script language="JavaScript"> function formsubmit() { arr=['jpeg','gif']; v=document.getElementById('file').value; t=v.split('.'); ext=t.pop(); ext=ext.toLowerCase(); if (in_array(ext,arr)) { // отправлять данные формы return true; } else { // сообщать пользователю что файл с данным расширением не может быть закачан return false; } } function in_array(needle, haystack, strict) { var found = false, key, strict = !!strict; for (key in haystack) { if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) { found = true; break; } } return found; } </script> </head>
<body> <form method="post" enctype="multipart/form-data" onsubmit="formsubmit();" action="/"> <input id="file" type="file" name="file" /> <input type="submit" /> </form> </body> </html>
|
|