JavaScript多个表单中文件上传网址的获得的代码示例
[html]
<form action='http://xxx.com/data' method='post'>
<input type="text" name="data" />
<input type="submit" name="Submit2" value="上传数据">
</form>
<form action='...' ... >
...
</form>
...
<form action='...' ... >
...
</form>
<form action='http://xxx.com/upload' enctype='multipart/form-data' method='post'>
<input type="file" name="fileUpload"/>
<input type="submit" name="Submit2" value="上传文件">
</form>
问题是如何获得这个文件上传的网址呢?
下面是 JavaScript 代码示例
[javascript]
function showUploadUrl() {
for(var i=0; i<document.forms.length; i++) {
var form = document.forms[i];
for (var j=0; j<form.elements.length;j++){
if ( form.elements[j].type==="file") {
alert("上传地址是:" + form.action);
}
}
}
}
连接
推荐阅读