Re: How to upload file at the same time as the rest of the form is submitted?

  •  12-16-2010, 1:08 AM

    Re: How to upload file at the same time as the rest of the form is submitted?

    Hi jerry2,
     
    Please try the example below
     
     
    <%@  language="VBScript" %>
    <!-- #include file="aspuploader/include_aspuploader.asp" -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Form - Start uploading manually </title>
        <link href="demo.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div class="demo">
            <h2>
                Start uploading manually</h2>
            <p>
                This sample demonstrates how to start uploading manually after file selection vs
                automatically.</p>
            <!-- do not need enctype="multipart/form-data" -->
            <form id="form1" method="POST">
                <%
                    Dim uploader
                    Set uploader=new AspUploader
                    uploader.MaxSizeKB=10240
                    uploader.Name="myuploader"
                    uploader.InsertText="Upload File (Max 10M)"
            
                     uploader.AllowedFileExtensions="*.jpg,*.png,*.gif,*.zip"
                    uploader.SaveDirectory="savefiles"
                    uploader.ManualStartUpload=true
                    
                %>
                <%=uploader.GetString() %>
                <br />
                <br />
                <br />
                <button id="submitbutton" onclick="doStart();return false;">
                    Start Uploading Files</button>
                <input type="submit" value="Submit" onclick="showSubmitMessage()" id="submit"  style="visibility:hidden"/>
             
            </form>
            <br />
            <br />
            <br />
            <%

    If Request.Form("myuploader")&""<>"" Then

        Dim list,i
        list=Split(Request.Form("myuploader"),"/")

        For i=0 to Ubound(list)
            if i>0 then
                Response.Write("<hr/>")
            end if
            Dim mvcfile
            Set mvcfile=uploader.GetUploadedFile(list(i))

            Response.Write("<div style='font-family:Fixedsys'>")
            Response.Write("Uploaded complete")
            Response.Write("</div>")
        Next
    End If

            %>
        </div>
    </body>
    </html>

    <script>
    function showSubmitMessage()
    {
    //submit page
    }
        function doStart()
        {
        
            var uploadobj = document.getElementById('myuploader');
            if (uploadobj.getqueuecount() > 0)
            {
                uploadobj.startupload();
                
            }
            else
            {
                alert("Please browse files for upload");
            }
        }
        
        function CuteWebUI_AjaxUploader_OnTaskComplete(task)
        {
            //fire after upload complete
              var submit=document.getElementById("submit");
              submit.click();
        }
    </script>
    Regards,
     
    Ken
View Complete Thread