
<form name="thisform" method="post"
action="<%=request.getContextPath()%>/movieManage.do" id="thisform" enctype="multipart/form-data">
<input type="file" name="theFile" onchange="document.getElementById('theFilePath').value=this.value"/>
<input type="hidden" id="theFilePath" name="theFilePath" value="">
</form>
注意:要有enctype="multipart/form-data"
Action代码:
String filePath = request.getParameter("theFilePath")
filePath既是上传文件的绝对路径。
浏览器中测试:
Firefox和IE中可以得到绝对路径。
做上传当然需要知道文件的位置.首先在你上传的jsp页面需要有一个表单form.在这个表单里有一个这样一个标签.在你点上传按钮的时候将你选中的文件传递到servlet或action这样的处理页面.在处理页面StringfileName=request.getParameter("fileName").这样就得到了文件名。然后你就可以使用文件流对这个文件进行上传 *** 作。如果还有问题直接HI我。不知你是不是用php开发的 php的话是在php.ini文件内设置的,其他语言应该也是对应的初始化文件中,找找应该能找到(php的路径是upload_tmp_dir = "盘:\xampp\tmp")欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)