用html5进行多文件上传的时候是一次性把所有已选择文件传到后台么

用html5进行多文件上传的时候是一次性把所有已选择文件传到后台么,第1张

html传多个文件对前端来说是一股脑的提交,但是其实主要还是看后台是如何接收的。后台可以设置一次性接收的文件数据,文件大小等等。其实就和平时的上传下载是一样的。

以下载为例:下载的时候,比如用迅雷下载,你的本机是否可以选择并行下载、逐个下载还可以停止、继续下载。同样的,上传也是一个类似的过程,主要依靠服务器代码进行管理设置。本质上,是两个计算机之间相互传递数据流而已。

当然,在默认的时候,服务器是接收多个文件的,比如javaweb中struts2接收文件默认是接收完所有文件然后再 *** 作的。

//改好了没问题..加文件试试

<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8" />

<script type="text/javascript">

function imgChange(next) {

if(next != null)

document.getElementById(next).style.display = ""

}

function validate() {

var phos = 2

for(i = 0i <2i++) {

if($("del" + i).checked == true)

phos--

}

for(i = 0i <4i++) {

if($("photoFile" + i).value != "")

phos++

}

if(phos >4) {

alert("图片太多,您最多总共可以保存4张图片!")

return false

}

return true

}

</script>

<form action="/addTrade.do" method="post" enctype="multipart/form-data" onSubmit="return validate()">

<!-- 上传照片-->

<div>

<table width="100%" border="0" cellspacing="0" cellpadding="0"

summary="upload pictures">

<tr id="tr_photoFile0">

<td width="119" align="right" class="title">

上传照片:

</td>

<td width="499">

<input type="file" name="photoFile0" id="photoFile0"

size="40" onChange='return imgChange("tr_photoFile1")' />

</td>

</tr>

<tr id="tr_photoFile1" style="display: none">

<td>

</td>

<td>

<input type="file" name="photoFile1" id="photoFile1"

onChange='return imgChange("tr_photoFile2")' size="40" />

</td>

</tr>

<tr id="tr_photoFile2" style="display: none">

<td>

</td>

<td>

<input type="file" name="photoFile2" id="photoFile2"

onChange='return imgChange("tr_photoFile3")' size="40" />

</td>

</tr>

<tr id="tr_photoFile3" style="display: none">

<td>

</td>

<td>

<input type="file" name="photoFile3" id="photoFile3"

onChange='return imgChange(null)' size="40" />

</td>

</tr>

</table>

</div>

<!--/ 上传照片-->

<input name="submit" type="submit" value="提交"/>

</form>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6299432.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-20
下一篇 2023-03-20

发表评论

登录后才能评论

评论列表(0条)

保存