Implementation

Last post 07-07-2011, 2:13 PM by Eric. 4 replies.
Sort Posts: Previous Next
  •  07-02-2011, 10:45 AM 68321

    Implementation

    As I am not a coding guru, I am trying to implement this demo version and see if I can get it to work. All I did was create a new upload.asp page and pasted this code into the HTML and changed the upload directory to a folder on the web server. When I then try to browse to the page to see if the uploader is visible, I get....
     

    HTTP Error 403.1 - Forbidden: Execute access is denied.
    Internet Information Services (IIS)

    The code I pasted is below.
     
     
    <% @ Language="VBScript" %>  
    <!--Step 1: Register Uploader to your page -->  
    <!-- #include file="aspuploader/include_aspuploader.asp" -->  
    <html>  
    <body>  
        <div>  
        <%
                  'Step 2: Create Uploader object     
                  Dim uploader   
                  Set uploader=new AspUploader   
                  'Step 3: Set a unique name to Uploader
          uploader.Name="myuploader"
                  uploader.SaveDirectory="uploaded_files"  
                  uploader.AllowedFileExtensions="*.jpg,*.png,*.gif"  
                  'Step 4: Render Uploader
                  uploader.Render()
        %>  
        </div>  
    </body>  
    </html>
     
     
    Can you help me determine what I'm not doing here? I probably am not understanding the deployment steps. Can you be more detailed in:
     
    1) Register Uploader To Your Page
     
    2) Create Uploader Object
     
    3)  Set a unique name to Uploader (This is pretty obvious)
     
    4) Render Uploader
  •  07-02-2011, 5:20 PM 68322 in reply to 68321

    Re: Implementation

    OK, I figured it out. I just modified my upload.htm file to include an inline frame pointing to one of the configured form-xxxxfile.asp pages and it works great.
     
    Is there a way that anytime an upload is made, an email can be generated to a particular email address with the date, time and filename?
     
    Even better, can a form field or two be included so that a person uploading can supply an email address or other relevent information that could be sent along with notification of the file being uploaded?
     
    We would love to be able to have an email sent to our art department with the uploading entity's:
     
    Date
    Time
    Filename
    Name
    email address
    phone number
    maybe even a link in the email to the file that has been uploaded to the server
     
    Am I asking too much?
  •  07-04-2011, 2:10 PM 68342 in reply to 68322

    Re: Implementation

    Hi StevenS,

    Please set property "UploadUrl", you can write email send code in the handler file. 

    <%   
            Dim uploader   
            Set uploader=new AspUploader   
            uploader.UploadUrl="myhandler.asp"  
            uploader.Render()   
        %>

    In the download package, you can find the following 3 files, these are the examples of  customization handler.  You can refer to them. 

    ajax-multiplefiles-handler.asp
    ajax-attachments-handler.asp
    misc-filemanager-handler.asp

    Thank you for asking
    Eric@cutesoft.net
  •  07-06-2011, 6:46 AM 68368 in reply to 68342

    Re: Implementation

    But can you collect information on the upload page where the user is selecting file(s) to upload and it be submitted immediately after the file has completed the upload?
     
    I guess what I am trying to say is that we are used to using "forms" and form fields for uploading files. Form fields were used in collecting particular information about the person submitting the upload.
     
    We would like to use a combination of the file being uploaded and an email being fired off with all the information that we require above in the previous post. And have the pertinent fields validated so that they are required before the file can be uploaded in the first place. We want that so purely anonymous uploads are not allowed. The form fields would be required to be completed before the upload could occur.
     
    This is what we previoulsy used:
     
    <form method="POST" enctype="multipart/form-data" name="FrontPage_Form1" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">
            <!--webbot bot="FileUpload" u-file="assets/FormResults/FileUploadResults.htm" s-format="HTML/BR" s-label-fields="TRUE" b-reverse-chronology="FALSE" s-email-format="TEXT/PRE" b-email-label-fields="TRUE" b-email-subject-from-field="FALSE" s-email-subject="Uploaded Artwork From Website Form" s-destination="uploaded/" s-category s-assignedto s-reviewstatus b-process-metainfo="FALSE" s-date-format="%A %B %d, %Y" s-time-format="%I:%M %p %Z" s-builtin-fields="Date Time" s-form-fields="FirstName LastName eMail Phone UploadFile1 UploadFile2 UploadFile3 NOTES " u-confirmation-url="upload_complete.htm" s-email-address="email@emailaddress.com" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><input TYPE="hidden" NAME="_charset_" VALUE="windows-1252"><!--webbot bot="FileUpload" endspan i-checksum="58985" --><div align="center">
              <center>
              <table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#111111" width="120" id="AutoNumber2">
                <tr>
                  <td><b><font color="#FFFFFF" face="Verdana" size="1">*</font><font color="#FFFFFF" face="Verdana" size="2">First Name</font></b></td>
                  <td><b><font color="#FFFFFF" face="Verdana" size="1">*</font><font color="#FFFFFF" face="Verdana" size="2">Last Name</font></b></td>
                </tr>
                <tr>
                  <td>
                  <!--webbot bot="Validation" s-display-name="First Name" b-value-required="TRUE" --><input type="text" name="FirstName" size="40" tabindex="1"></td>
                  <td>
                  <!--webbot bot="Validation" s-display-name="Last Name" b-value-required="TRUE" --><input type="text" name="LastName" size="40" tabindex="2"></td>
                </tr>
                <tr>
                  <td><b><font color="#FFFFFF" face="Verdana" size="1">*</font><font color="#FFFFFF" face="Verdana" size="2">eMail Address</font></b></td>
                  <td><b><font color="#FFFFFF" face="Verdana" size="1">*</font><font color="#FFFFFF" face="Verdana" size="2">Phone</font></b></td>
                </tr>
                <tr>
                  <td>
                  <!--webbot bot="Validation" s-display-name="eMail Address" b-value-required="TRUE" --><input type="text" name="eMail" size="40" tabindex="3"></td>
                  <td>
                  <!--webbot bot="Validation" s-display-name="Phone Number" b-value-required="TRUE" --><input type="text" name="Phone" size="40" tabindex="4"></td>
                </tr>
                <tr>
                  <td colspan="2">
                  <b><font color="#FFFFFF" size="1" face="Verdana">* Required in
                  case of questions about your inquiry</font></b></td>
                </tr>
              </table>
              </center>
            </div>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
            <div align="center">
              <pre style="margin-top: 0; margin-bottom: 0"><b><font face="Verdana" color="#FFFFFF" size="3">NOTES</font></b></pre>
            </div>
            <div align="center">
              <center>
              <pre style="margin-top: 0; margin-bottom: 0"><textarea rows="6" name="NOTES" cols="65" tabindex="5"></textarea></pre>
              </center>
            </div>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
            <p style="margin-top: 0; margin-bottom: 0" align="center"><b>
            <font face="Verdana" color="#FFFFFF">Please Select Your File Below</font></b></p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">
            <input type="file" name="UploadFile1" size="50" tabindex="6"></p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">
            <input type="file" name="UploadFile2" size="50" tabindex="7"></p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">
            <input type="file" name="UploadFile3" size="50" tabindex="8"></p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">
            <input type="submit" value="Submit" name="SubmitButton" tabindex="9"></p>
            <p style="margin-top: 0; margin-bottom: 0" align="center">&nbsp;</p>
          </form>
     
    Thanks for any assistance.
     
    SteveS
  •  07-07-2011, 2:13 PM 68378 in reply to 68368

    Re: Implementation

    Hi SteveS,
     
    You can run the following two examples on your asp uploader installation directly:
     
    example1:

    <%@ 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>
    </head>
    <body>
     <div class="demo">
       <!-- 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.MultipleFilesUpload=true    
        uploader.ManualStartUpload=true    
        %>
        <%=uploader.GetString() %>   
        <br />
        
       <table id='clientTable' style="display: none; font-size: 9pt; border-collapse: collapse"
        border="1" cellspacing="0" cellpadding="5">
        <tr>
         <td>
          FileName
         </td>
         <td>
          Description
         </td>
         <td>
          Status
         </td>
        </tr>
       </table>  
        <br />
        <button id='btnUpload' style="display: none;" onclick="Upload_Click();return false;">Start Upload</button> 
       </form>
     </div>
    <script type="text/javascript">
        var btnUpload = document.getElementById("btnUpload");
        var clientTable = document.getElementById("clientTable");
        var uploader = document.getElementById('myuploader');
        //var buttonTell = document.getElementById('buttonTell');
        var buttonTellClicked = false;

        function Upload_Click() {   
            var uploadobj = document.getElementById('myuploader');
      if (uploadobj.getqueuecount() > 0)
      {
          for(var i=1;i<clientTable.rows.length;i++)
          {
            var fieldValue= clientTable.rows.item(i).cells[1].children[0].value;       
            if(fieldValue==null||fieldValue.length<1)
            {
                alert("Please fill in values!");
                return;
            }      
       }
       uploadobj.startupload();
      }
      else
      {
       alert("Please browse files for upload");
      }
        }
        function buttonTell_Click() {
            buttonTellClicked = true;
            var items = uploader.getitems();
            for (var i = 0; i < items.length; i++) {
                switch (items[i].Status) {
                    case "Queue":
                    case "Upload":
                        uploader.startupload();
                        return false;
                }
            }
            return true;
        }
        function CuteWebUI_AjaxUploader_OnPostback() {
            if (buttonTellClicked) {
                buttonTell.click();
                return false;
            }
        }
        function CuteWebUI_AjaxUploader_OnQueueUI(files) {
            btnUpload.style.display = files.length > 0 ? "" : "none";
            clientTable.style.display = files.length > 0 ? "" : "none";
            ShowMyClientTable(files);
            return false;
        }

        function ShowMyClientTable(files) {
            var map = {}
            var newlist = [];
            for (var i = 1; i < clientTable.rows.length; i++) {
                var row = clientTable.rows.item(i);
                row._scan = false;
                map[row._filekey] = row;
            }
            //update existing row
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var row = map[file.InitGuid || file.FileName];
                if (row == null) {
                    newlist.push(file);
                    continue;
                }
                row._scan = true;
                UpdateToRow(row, file);
            }
            //delete removed row
            for (var i = 1; i < clientTable.rows.length; i++) {
                var row = clientTable.rows.item(i);
                if (!row._scan) {
                    clientTable.deleteRow(i);
                    i--;
                }
            }
            //add new row:
            for (var i = 0; i < newlist.length; i++) {
                var file = newlist[i];
                var row = clientTable.insertRow(-1);
                row.insertCell(-1);
                row.insertCell(-1);
                row.insertCell(-1);
                UpdateToRow(row, file);
            }
        }
        function UpdateToRow(row, file) {

            row._file = file;
            row._filekey = file.InitGuid || file.FileName;
            if (!row._textbox) {
                row._textbox = document.createElement("INPUT");
                row._textbox.type = "text";
                row.cells.item(1).appendChild(row._textbox);
            }
            row._textbox.onchange = function() {
                file.SetClientData(row._textbox.value);
            }
            row.cells.item(0).innerHTML = file.FileName;
            switch (file.Status) {
                case "Queue":
                    row.cells.item(2).innerHTML = "<a href='#' onclick='CancelQueueItem(this);return false'>remove</a>";
                    break;
                case "Finish": //uploaded
                case "Upload": //uploading
                case "Error": //cancelled
                default:
                    row.cells.item(2).innerHTML = file.Status;
                    break;
            }
        }
        function CancelQueueItem(link) {
            var td = link.parentNode;
            var row = td.parentNode;
            var file = row._file;
            file.Cancel();
        }
        //prevent duplicated items:
        function CuteWebUI_AjaxUploader_OnSelect(files) {
            var sames = [];
            var items = uploader.getitems();
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var exists = false;
                for (var j = 0; j < items.length; j++) {
                    var item = items[j];
                    if (item.FileName == file.FileName) {
                        exists = true;
                    }
                }
                if (exists) {
                    sames.push(file.FileName);
                    file.Cancel();
                }
            }
            if (sames.length > 0) {
                alert("These file(s) are already in the queue : \r\n\t" + sames.join('\r\n\t'));
            }
        }
    </script>
    </body>
    </html>

     
    example2:

    <%@ 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();
     }
     function CuteWebUI_AjaxUploader_OnQueueUI(files) {     
            //return false;
        }   
        function CuteWebUI_AjaxUploader_OnSelect(files) {
          var form1= document.forms[0];    
          if(form1.fname.value==""){ 
             window.alert("please input first name!"); 
             form1.fname.focus() 
             return false; 
          }
          if(form1.lname.value==""){ 
             window.alert("please input first name!"); 
             form1.lname.focus() 
             return false; 
          }
        }   
     </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">
       First Name: <input type="text" name="fname" />
                <br />
                Last Name: <input type="text" name="lname" />
                <br />
       <%
       Dim uploader
       Set uploader=new AspUploader
       uploader.MaxSizeKB=10240
       uploader.Name="myuploader"
       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"),"/")
     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>

    Thanks for asking
View as RSS news feed in XML