Suppose a page has multiple forms, one of which has file uploads,
Copy Code code as follows:
<form action= ' http://xxx.com/data ' method= ' post ' >
<input type= "text" name= "Data"/>
<input type= "Submit" Name= "Submit2" value= "Upload data" >
</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= "Upload file" >
</form>
The question is how to get this file to upload the URL?
The following is a sample JavaScript code
Copy Code code as follows:
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 ("Upload address is:" + form . Action);
}
}
}
}