【问题标题】:Jquery uploadify just one file upload and other upload stay at 100%?Jquery uploadify 只上传一个文件,其他上传保持 100%?
【发布时间】:2010-06-01 08:04:02
【问题描述】:

首先,我在本地服务器上工作,xampp,jquery uploadify 只上传一个文件,其他文件在 100% 上,并保持这种状态。当单击 x 按钮停止时,我收到此消息:'未捕获的异常:错误动作脚本' ??有什么想法吗?这是 wordpress 项目。 我的代码:

uploadifyObj={
            uploader       : '<?php echo $full_path_ajax_swf_dir; ?>',
            script         : '<?php echo $full_path_ajax_php; ?>',
            scriptData     : {'extra' : '5'},
            cancelImg      : '<?php echo WP_PLUGIN_URL . '/' . $plugin_dir_name.'/iks.png';?>',
            folder : 'path',
            queueID        : 'fileQueue',
            auto           : true,
            multi          : true,
            method : 'GET',
            fileDesc: 'Image files',
            fileExt        : '*.jpg;*.jpeg;*.png',
            buttonText : 'Choose...',
            simUploadLimit: 20,
            onComplete       : function(event, queueID, fileObj, response, data) {                
                alert(response);

            },
           onError : function(event,queueID, fileObj){
               alert(event);
           },
           onAllComplete : function(event, data){
               alert('Everything is over')l
           }

        };

        $("#uploadify").uploadify(uploadifyObj);

和php部分:

 if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetPath = WP_CONTENT_DIR. '/uploads/'.$plugin_dir_name.'/'. get_option('myFolder') .'/';
        $targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];


        $jsonResponse->msg = $targetFile;
        move_uploaded_file($tempFile,$targetFile);
        /*

        if(!file_exists($targetFile)) {
            move_uploaded_file($tempFile,$targetFile);
            $jsonResponse->msg = 'file dont exist';
        }
        else{
            $jsonResponse->msg = 'file exist : '.$_FILES['Filedata']['name'];
        }       */
        print json_encode($jsonResponse);

    }

【问题讨论】:

  • 那个 php 文件的文件名是什么?这个 ($full_path_ajax_php) 有吗?
  • 文件名是 do_job 并且是 do_job.php 文件的完整路径
  • $full_path_ajax_php = WP_PLUGIN_URL 。 '/' 。 $plugin_dir_name 。 '/do_job.php';
  • 这是错字吗? onAllComplete : function(event, data){ alert('Everything is over')l }警报后有事...
  • 错字,对不起,我只是尝试在我的本地服务器上上传示例,并且工作正常,没有错误。 :( 问题出在哪里?有什么想法吗?

标签: jquery wordpress uploadify


【解决方案1】:

您的自定义 onComplete 侦听器必须 return true 允许 Uploadify 在文件上传完成后删除队列项。

红色“x”按钮取消上传。当您单击它时,您是在告诉 Uploadify 的 Flash 上传器停止上传相关文件。 Flash 抛出错误,因为它被告知取消已完成的文件上传。

如果您不希望文件在完成上传后从队列中消失(当自定义 onComplete 侦听器返回 true 时会发生这种情况),您必须移除或替换取消按钮或其事件侦听器。

【讨论】:

    猜你喜欢
    • 2012-11-30
    • 2011-12-15
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多