Live Support, Chat, Upload Control and Rich Text Editor
Welcome to Support forums Sign in | Join | Help |Client Center
in Search

Redirect When Upload Complete

Last post 05-04-2011, 6:39 PM by msandwisch. 10 replies.
Sort Posts: Previous Next
  •  04-12-2011, 6:05 AM 67124

    Redirect When Upload Complete

    I need to redirect to a different page when the upload completes.  I tried a few things with the javascript api but I'm not sure where to put the redirect code.  Any ideas?
    Filed under: , ,
  •  04-12-2011, 10:27 AM 67125 in reply to 67124

    Re: Redirect When Upload Complete

    Dear msandwisch,
     
    You can try the following snippet:
     
    <%@ 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>Simple File Upload - use SaveDirectory property</title>
     <link href="demo.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
     <div class="demo">
            <h2>Simple File Upload with Custom Validation</h2>
      <p>A basic sample demonstrates the use of the Upload control. The user is allowed to select multiple files and upload them to a specified location (savefiles) directly. It also demonstrates Client side validation of file size/types prior to uploading the files to a server.</p>
      <ul>
       <li>Allowed file types is set to: jpg, gif, png, zip</li>
      </ul>
     <%
     Dim uploader
     Set uploader=new AspUploader
     uploader.MultipleFilesUpload=true
     uploader.MaxSizeKB=10240
     uploader.InsertText="Select multiple files (Max 10M)"
     uploader.SaveDirectory="savefiles"
     uploader.AllowedFileExtensions="*.jpg,*.png,*.gif,*.zip"
     %>
     <%=uploader.GetString() %>
     
     <script type='text/javascript'>
     function CuteWebUI_AjaxUploader_OnTaskComplete(task)
     {
      var div=document.createElement("DIV");
      var link=document.createElement("A");
      link.setAttribute("href","savefiles/"+task.FileName);
      link.setAttribute("target","_blank");
      link.innerHTML="You have uploaded file: savefiles/"+task.FileName;
      div.appendChild(link);
      document.body.appendChild(div);
     }
     function CuteWebUI_AjaxUploader_OnPostback()
        {
            window.location("http://www.google.com");        
        }

     </script>
    </div>
    </body>
    </html>

     

    Thank you for asking
  •  04-12-2011, 12:51 PM 67130 in reply to 67125

    Re: Redirect When Upload Complete

    I copied the additional lines you suggested and it still is not redirecting.  Then I eliminated everything I had and copied your post from top to bottom.  Is there something else I could be missing???
  •  04-12-2011, 3:30 PM 67132 in reply to 67130

    Re: Redirect When Upload Complete

    Dear msandwisch,
     
    You can post your code here, we will test your code.
     
    Thanks for your business
  •  04-12-2011, 3:42 PM 67133 in reply to 67132

    Re: Redirect When Upload Complete

    <!-- #include file="include_aspuploader.asp" -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link rel="stylesheet" type="text/css" href="data/stylesheets/default.css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Mungo Report - Extracting Valuable News From Trash</title>

    </head>

    <body>
    <table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
      <tr>
        <td><!-- #include file ="header.asp" --></td>
      </tr>
      <tr>
        <td><span class="AdSmall"><strong>You Are Here</strong>:</span></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="75%" align="center" valign="top"><p><object id="player2" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player2" width="512" height="384">
              <param name="movie" value="player.swf" />
              <param name="allowfullscreen" value="true" />
              <param name="allowscriptaccess" value="always" />
              <param name="flashvars" value="file=mungo.flv" /><param name="LOOP" value="false" />
              <embed
                src="player.swf"
                width="512"
                height="384" loop="false"
                type="application/x-shockwave-flash"
                id="player3"
                name="player2"
                allowscriptaccess="always"
                allowfullscreen="true"
                flashvars="file=mungo.flv"
            />        
    </object></p>
              <p class="AdSmall">
     <%
     Dim uploader
     Set uploader=new AspUploader
     uploader.MultipleFilesUpload=true
     uploader.MaxSizeKB=10240
     uploader.InsertText="Select multiple files (Max 10M)"
     uploader.SaveDirectory="data/uploads/rawvideo"
     uploader.AllowedFileExtensions="*.jpg,*.png,*.gif,*.zip"
     %>
     <%=uploader.GetString() %>
     
     <script type='text/javascript'>
     function CuteWebUI_AjaxUploader_OnTaskComplete(task)
     {
      var div=document.createElement("DIV");
      var link=document.createElement("A");
      link.setAttribute("href","savefiles/"+task.FileName);
      link.setAttribute("target","_blank");
      link.innerHTML="You have uploaded file: savefiles/"+task.FileName;
      div.appendChild(link);
      document.body.appendChild(div);
     }
     function CuteWebUI_AjaxUploader_OnPostback()
        {
            window.location("http://www.google.com");        
        }

     </script>

            
            &nbsp;</p>
              <p align="left" class="TextBold">&nbsp;</p>
              </td>
            <td width="25%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="AdSmall"><div align="center">Sponsored Ads</div></td>
              </tr>
              <tr>
                <td class="AdSmall"><div align="center"><img src="data/ads/certainsound.jpg" width="200" height="100" /><br />
                  <br />
                </div></td>
              </tr>
              <tr>
                <td class="AdSmall"><div align="center"></div></td>
              </tr>
              <tr>
                <td align="center"><a href="http://www.gallonlaw.com" target="_blank"><img src="data/ads/200x217/gallon.jpg" width="200" height="217" border="0" /></a></td>
              </tr>
              <tr>
                <td align="center">&nbsp;</td>
              </tr>
              <tr>
                <td align="center"><a href="http://www.sandsites.com" target="_blank"><img src="data/ads/200x217/sandsites.jpg" width="200" height="217" border="0" /></a></td>
              </tr>
              <tr>
                <td align="center">&nbsp;</td>
              </tr>
              <tr>
                <td align="center"><img src="data/ads/200x217/here.jpg" width="200" height="217" /></td>
              </tr>
              <tr>
                <td><div align="center">Sponsored Ads</div></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td align="center">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table>
    <!-- #include file ="footer.asp" -->
    </body>
    </html>
  •  04-13-2011, 11:02 AM 67147 in reply to 67133

    Re: Redirect When Upload Complete

    Dear msandwisch,
     
    Please change
    function CuteWebUI_AjaxUploader_OnPostback()
    {
    window.location("http://www.google.com");
    }
    to
     
    function CuteWebUI_AjaxUploader_OnPostback()
    {
     
    window.location.href="http://www.google.com";
    }
    After done, please test it again.
     
    Thank you for asking
     
  •  04-13-2011, 7:55 PM 67153 in reply to 67147

    Re: Redirect When Upload Complete

    That worked.  One more question.  How can I get the filename that is uploaded?  I want to redirect in the format www.example.com/page.asp?FileName=xxx.
  •  04-14-2011, 8:23 AM 67160 in reply to 67153

    Re: Redirect When Upload Complete

    Dear msandwisch,
     
    task.FileName is the file name of uploaded file:
     
     function CuteWebUI_AjaxUploader_OnTaskComplete(task)
     {
      var div=document.createElement("DIV");
      var link=document.createElement("A");
      link.setAttribute("href","savefiles/"+task.FileName);
      link.setAttribute("target","_blank");
      link.innerHTML="You have uploaded file: savefiles/"+task.FileName;
      div.appendChild(link);
      document.body.appendChild(div);
     }
     
    Thank you for asking
  •  04-14-2011, 2:57 PM 67169 in reply to 67160

    Re: Redirect When Upload Complete

    When I run the script, the FileName comes back as "undefined".  This is the code I'm using:
     
     <script type='text/javascript'>

    function CuteWebUI_AjaxUploader_OnPostback(task)
    {
     
    window.location.href="http://www.domain.com/page.asp?File=" + task.FileName;
    }

     </script>
     
  •  04-14-2011, 8:32 PM 67175 in reply to 67169

    Re: Redirect When Upload Complete

    Hi msandwisch,
     
    Try the code below
     
     
     var fileName="";
     function CuteWebUI_AjaxUploader_OnTaskComplete(task)
     {
        fileName=task.FileName;
        var div=document.createElement("DIV");
        var link=document.createElement("A");
        link.setAttribute("href","savefiles/"+task.FileName);
        link.setAttribute("target","_blank");
        link.innerHTML="You have uploaded file: savefiles/"+task.FileName;
        div.appendChild(link);
        document.body.appendChild(div);
     }
     function CuteWebUI_AjaxUploader_OnPostback()
        {
            window.location.href="http://www.domain.com/page.asp?File="+fileName;        
        }
     
     
    Regards,
     
    Ken
  •  05-04-2011, 6:39 PM 67451 in reply to 67175

    Re: Redirect When Upload Complete

    Works great.  Thanks for all the help.
View as RSS news feed in XML
Powered by ASP.Net
Copyright 2003 - 2017 CuteSoft Components Inc.. All rights reserved.