上传和下载一页

时间:2012-10-10 08:06:49

标签: html asp-classic upload download

我创建了支持下载和上传功能的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>

目前,上传无效。我怎么解决这个问题?感谢。

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

主要问题是包含另外两种形式的主要形式。你必须关闭它,因为java脚本无法找到上传表单