2012-09-24 97 views
0

我知道这个问题已经有一些线程,但没有一个对我有帮助。Uploadify - onComplete || onAllComplete不工作

我有一个图像管理器,我想用“onComplete”事件重新加载页面,但它不适用于我。

你可以看到一个例子:http://graficnova.com/uploadifytest/imgLoader.php

一切工作成功!!,但你需要刷新:(按F5键

THX和对不起我的英语

代码!

头:

<script type="text/javascript"> 
     $(function() { 
      $("#fileInput").uploadify({ 
       width : 100, 
       swf   : 'swf/uploadify.swf', 
       uploader  : 'php/uploadify.php',      
       queueID : 'imgloadList', 
       oncomplete : function() { 
        alert('hello world?'); //<- THIS NOT WORK 
       } 
      });    
     });     
    </script> 

PHP: uploadify.php

if (!empty($_FILES)) { 
$tempFile = $_FILES['Filedata']['tmp_name']; 

//$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; 


$targetPath = 'xxxxx/xxxx/xxxx/xxxx'; 



$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; 



// Validate the file type 
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions 
$fileParts = pathinfo($_FILES['Filedata']['name']); 

if (in_array($fileParts['extension'],$fileTypes)) {  
    move_uploaded_file($tempFile,$targetFile); 
    echo '1'; //<- return response 
} else { 
    echo 'Invalid file type.'; //<- return response 
} 

}

+0

http://www.uploadify.com/documentation/uploadify/onqueuecomplete/ – hardba11

回答

2

基础上Uploadify文档,没有一个onComplete事件,但有一个'onUploadComplete'事件:

触发一次为每个文件上传时,是完成是否成功或返回错误。如果您想知道上传是否成功,最好使用onUploadSuccess事件或onUploadError事件。

可能要试一试。或退出onQueueComplete

+0

onComplete已弃用。 –