HTML basic tuto...LOGIN

HTML basic tutorial form upload file field

Upload file field

##Syntax format: <input type = “file” attribute = “attribute” />

Common attributes

  • name: the name of the form element

  • value: the value of the form element, this value is actually uploaded file name. The value attribute is a read-only attribute. The content of this value can only come from manually selected uploaded files, and the user cannot specify a path. For security reasons, value is read-only.

Note: Now only the upload file box can be implemented, but the upload function cannot be truly implemented. The upload function is implemented with PHP.

Note:

  • When you need to upload a file, the form submission method can only be post method,

  • You must add enctype="multipart/form-data" to the form tag

Example:

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>用户注册</title>
    </head>
    <body>
        <font size="5" color="red">欢迎注册php.cn</font>
        <form name="user" method="post" action="" enctype="multipart/form-data" >
            用户名:<input type="text" name="username"/>
            <br/>
            密码:<input type="password" name="userpwd"/>
            <br/>
            性别:<input type="radio" name="sex" value="男" checked=checked>男
            <input type="radio" name="sex" value="女">女
            <br/>
            爱好:<input type="checkbox" name="hobby" value="运动">运动
            <input type="checkbox" name="hobby" value="看电影">看电影
            <input type="checkbox" name="hobby" value="编程" checked="checked">编程
            <input type="checkbox" name="hobby" value="宅着">宅着
            <br/>所在地:
            <select name="city">
                <option value="北京">北京<option>
                <option value="上海">上海<option>
                <option value="杭州" selected="selected">杭州<option>
                <option value="南京">南京<option>
                <option value="合肥">合肥<option>
            </select>
            <br/>个性介绍:<br/><textarea name=" introduction" cols="30" rows="4"></textarea>
            <br/>上传头像:<input type="file" name="upload"/>
            <br/><input type="submit" value="提交信息"/>
            <input type="reset" value="重填一次"/>
            <input type="image" src="http://photocdn.sohu.com/20160107/mp52903269_1452135104978_1_th.png" width="70"/>
            <input type="button" onclick="javascript:window.close()" value="关闭窗口"/>
        </form>
    </body>


Next Section

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>用户注册</title> </head> <body> <font size="5" color="red">欢迎注册php.cn</font> <form name="user" method="post" action="" enctype="multipart/form-data"> 用户名:<input type="text" name="username"/> <br/> 密码:<input type="password" name="userpwd"/> <br/> 性别:<input type="radio" name="sex" value="男" checked=checked>男 <input type="radio" name="sex" value="女">女 <br/> 爱好:<input type="checkbox" name="hobby" value="运动">运动 <input type="checkbox" name="hobby" value="看电影">看电影 <input type="checkbox" name="hobby" value="编程" checked="checked">编程 <input type="checkbox" name="hobby" value="宅着">宅着 <br/>所在地: <select name="city"> <option value="北京">北京<option> <option value="上海">上海<option> <option value="杭州" selected="selected">杭州<option> <option value="南京">南京<option> <option value="合肥">合肥<option> </select> <br/>个性介绍:<br/><textarea name=" introduction" cols="30" rows="4"></textarea> <br/>上传头像:<input type="file" name="upload"/> <br/><input type="submit" value="提交信息"/> <input type="reset" value="重填一次"/> <input type="image" src="http://photocdn.sohu.com/20160107/mp52903269_1452135104978_1_th.png" width="70"/> <input type="button" onclick="javascript:window.close()" value="关闭窗口"/> </form> </body>
submitReset Code
ChapterCourseware