表单提交数据和ajax提交数据
参数enctype:
第一种形式(提交文件时的参数):
<form action="" method="post" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<p>用户:<input type="text" name="user" placeholder="username"></p>
<p>密码:<input type="password" name="pwd" placeholder="password"></p>
<input type="file" name="file">
<input type="submit" value="提交">
</form>
第二种形式(默认参数):
<form action="" method="post" enctype="application/x-www-form-urlencoded" novalidate>
{% csrf_token %}
<p>用户:<input type="text" name="user" placeholder="username"></p>
<p>密码:<input type="password" name="pwd" placeholder="password"></p>
<input type="file" name="file">
<input type="submit" value="提交">
</form>
注意:在提交二进制文件时,必须使用post方法,使用get方法在后端的get中不能获取到文件对象,只能获取到一个字符串(文件名)
刷初步设计被拆包时间戳
浙公网安备 33010602011771号