开发者

Can Uploadify send e-mail on complete?

开发者 https://www.devze.com 2022-12-31 02:22 出处:网络
Uploadify is a jQuery/Flash plugin for uploading multiple files. It\'s working great, except I can\'t figure out how trigger e-mail when all files are complete. If I try to add something like <% Se

Uploadify is a jQuery/Flash plugin for uploading multiple files. It's working great, except I can't figure out how trigger e-mail when all files are complete. If I try to add something like <% SendEmail(); %> to the onAllComplete parameter, it just sends the e-mail when the page loads.

Is there a way to do this within the handler recommended here or from this post? Or is there some way to trigger a post in the onAllComplete parameter?

<script type="text/javascript">
    // <![CDATA[
    var FirstName = $('[id$=HiddenField4]').val();
    var MiddleName = $('[id$=HiddenField5]').val();
    var ClientName = $('[id$=HiddenField6]').val();
    var queueSize = $('#fileInput').uploadifySettings('queueSize');
    $(document).ready(function() {
        $('#fileInput').uploadify({
            'uploader': 'scripts/uploadify/uploadify.swf',
            'script': 'Upload.ashx',
            'scriptData': { 'first': FirstName, 'middle': MiddleName, 'client': ClientName, 'queueSize': queueSize },
            'cancelImg': 'scripts/uploadify/cancel.png',
            'auto': true,
            'multi': true,
            'fileDesc': 'Image Files',
            'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.pdf',
            'queueSizeLimit': 90,
            'sizeLimit': 10000000,
            'buttonText': 'Upload Documents',
            'folder': '/uploads',
            'onComplete': function(event, queueID, fileObj, response, data) {
                 alert(response);
            },
            'onAllComplete': function(event, queueID, fileObj, response, data) {
                 <% SendEmail(); %>
            },
            'buttonImg': 'images/upload.png'
开发者_Python百科         });
      });
      // ]]></script>

I've also tried queueSize declaring it as

var queueSize = $(".uploadifyQueueItem").size();

queueSize always posts as 0 when I debug my handler.


You could put the instruction to send the E-Mail into the script that receives the uploaded file (Upload.ashx in your case.)

That file will be called when the upload has been finalized.

An alternative would be making an Ajax call in the onComplete callback, calling another ashx script that sends out the E-Mails. Anyway, there is no JavaScript way of sending out the E-Mail, you will have to do that on the server side.


You need to solve this at the server side. But Uploadify is an entirely client side script (JS+Flash). You need to write/invoke the mailing code in the server side which get invoked by an ajaxical call which you fire in onAllComplete. You can use jQuery.ajax or consorts for this.

E.g.

        'onAllComplete': function(event, queueID, fileObj, response, data) {
             $.post('somescript.aspx', paramsWhichSignalsServerToSendMail);
        },
0

精彩评论

暂无评论...
验证码 换一张
取 消