Uploadify:等待move_uploaded_file直到触发“onUploadSuccess”

时间:2013-04-18 09:31:51

标签: php uploadify

我正在尝试通过uploadify上传大型视频文件,但一旦文件变大(> 800MB),onUploadSuccess事件就会在move_uploaded_file完成之前触发。有没有办法让uploadify等待实际的成功,甚至在完成上传和实际成功之后显示某种等待消息(如“整理上传”或其他东西)?
这是我upload.php的代码:

if($video = wire('pages')->get($_POST['id'])) {
if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
    $targetFile = preg_replace('/ /','_',$targetFile);
    // Validate the file type
    $fileTypes = array('mov','mp4','m4v'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        if(move_uploaded_file($tempFile,$targetFile)) {
            $file = preg_split("/\//", $targetFile);
            $video->filename = array_pop($file);
            $video->video_status = 'transcode';
            $video->addStatus('Page::statusUnpublished');
            $video->save();
            echo $video->filename." gespeichert";
        }
    } else {
        echo 'Invalid file type.';
    }
}
}

谢谢,
托马斯

0 个答案:

没有答案