write additional form data including filename an folder (per image uploaded) to a database

Last post 05-17-2011, 8:43 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  05-14-2011, 3:53 PM 67574

    write additional form data including filename an folder (per image uploaded) to a database

    I am writing an application which requires several steps
     
    1. creation of a user account
    2. creation of a folder for that users images
    3.uploading the images
    4. writing the image data (folder name and filename along with userID and other user specific credentials) to a database table
    5. On completion of file uploads, generating XML based on the data entered into the table at step 5 to integrate with a flash based image viewer.
     
    The issue I have, is how to process each f the files an all the necessary client data to the database as they are successfully uploaded. Everything else is in place but im currently using a "one by one" file uploader which uploads AND cretes the DB entry at the same time once the form is submitted and would far rather use the multiple file upload capability of this tool.
     
    How do I, once a file is successfully uploaded and stored in its appropriate folder for the client, modify the asp code to allow me to also write the relevant client data record? I knw I have to pass in parameters for the relevant clientID, event type and various other parameters - but IM realy not certain how or more importantly "where" to modify the source to do the database record creation.
     
    Also if I have a form elements such as clientID, name or username....how and where are these  accessed and in what format? 
     
    Any help would be greatly appreciated.
    Paul 
     
  •  05-17-2011, 8:43 PM 67596 in reply to 67574

    Re: write additional form data including filename an folder (per image uploaded) to a database

    Hi PKKSW,
     
    Please test the example below
     
    Mehtod CuteWebUI_AjaxUploader_OnPostback() will fire after all file upload complete.
     
    The red code shows you how to get the file info what you need to save into database.(two places can get it)
     
    <%@ 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 - Multiple files upload
        </title>
        <link href="demo.css" rel="stylesheet" type="text/css" />
        
        <script type="text/javascript">
        function CuteWebUI_AjaxUploader_OnPostback() {
            //submit the form after the file have been uploaded:
            document.forms[0].submit();
        }
        //get the upload file info
        function CuteWebUI_AjaxUploader_OnQueueUI(list)
        {
            var name=list[0].FileName
            var size=list[0].FileSize // (or -1)
            var stat=list[0].Status // Finish|Error|Upload|Queue
            var func=list[0].Cancel;
      
        }
        </script>
    </head>
    <body>
        <div class="demo">                        
            <h2>Selecting multiple files for upload</h2>
            <p>ASP Uploader allows you to select multiple files and upload multiple files at once.</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.Tempdirectory="temp"
                uploader.InsertText="Upload File (Max 10M)"
                uploader.MultipleFilesUpload=true
                %>
                <%=uploader.GetString() %>
                </form>
                
                <br/><br/>
    <%

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

        Dim list,i
        
        'Gets the GUID List of the files based on uploader name
        list=Split(Request.Form("myuploader"),"/")
        'get the upload file info
        For i=0 to Ubound(list)
            if i>0 then
                Response.Write("<hr/>")
            end if
            Dim mvcfile
            
            'get the uploaded file based on GUID
            Set mvcfile=uploader.GetUploadedFile(list(i))

            Response.Write("<div style='font-family:Fixedsys'>")
            Response.Write("Uploaded File:")
             'Gets the name of the file.
            Response.Write("<br/>FileName: ")
            Response.Write(mvcfile.FileName)
            'Gets the size of the file.
            Response.Write("<br/>FileSize: ")
            Response.Write(mvcfile.FileSize)
            'Gets the temp file path.
            Response.Write("<br/>FilePath: ")
            Response.Write(mvcfile.FilePath)
            Response.Write("</div>")
            'Copys the uploaded file to a new location.    
            mvcfile.CopyTo("/uploads")            
            'Moves the uploaded file to a new location.    
            mvcfile.MoveTo("/uploads")   

        Next
    End If

    %>
                
        </div>
    </body>
    </html>
     
    Regards,
     
    Ken
View as RSS news feed in XML