0

我创建了支持下载和上传功能的 asp 表单。见下文

<html>
    <head>
        <title>Testing</title>
        <script type="text/javascript">

            function clickUpload() {
                document.getElementById("UploadFile").click();
            }

            function clickDownload() {
                document.getElementById("DownloadForm").submit();
            }

            function MakeUpload() {
                document.getElementById("UploadForm").submit();
            }

        </script>
    </head>
    <body>
        <form action="Test1.asp">
            <input type="button" value="Upload" onclick="clickUpload();" />
            <input type="button" value="Download" onclick="clickDownload();" />
            <form id="UploadForm" action="test3.asp" enctype="multipart/form-data">
                <input type="file" id="UploadFile" onchange="MakeUpload();" style="display:none" />
            </form>
            <form id="DownloadForm" action="Test4.asp">
            </form>
        </form>
    </body>
</html>

目前,上传不起作用。我该如何解决这个问题?谢谢。

4

2 回答 2

1

不能嵌套 FORM 标记。如果您删除外部 FORM 标签,它应该可以工作。但是你需要提交给“Test1.asp”的FORM吗?

<html>
    <head>
        <title>Testing</title>
        <script type="text/javascript">

            function clickUpload() {
                document.getElementById("UploadFile").click();
            }

            function clickDownload() {
                document.getElementById("DownloadForm").submit();
            }

            function MakeUpload() {
                document.getElementById("UploadForm").submit();
            }

        </script>
    </head>
    <body>
            <input type="button" value="Upload" onclick="clickUpload();" />
            <input type="button" value="Download" onclick="clickDownload();" />
            <form id="UploadForm" action="test3.asp" enctype="multipart/form-data">
                <input type="file" id="UploadFile" onchange="MakeUpload();" style="display:none" />
            </form>
            <form id="DownloadForm" action="Test4.asp">
            </form>
    </body>
</html>
于 2012-10-10T21:42:00.543 回答
0

主要问题在于包含其他两个表单的主表单。您必须关闭它,因为 java 脚本无法找到上传表单

于 2012-10-10T08:29:22.893 回答