Beispiel #1
0
 static function getPreviewFileStream($id)
 {
     $file = Files::find()->getById($id);
     if ($file->isNewRecord()) {
         return;
     }
     $fileName = rtrim($file->path, '/\\') . DS . $file->name . '.' . $file->ext;
     if ($file->type == 1 || $file->type == 2) {
         $fileNamePreview = rtrim($file->path, '/\\') . DS . $file->name . '-preview.flv';
         $lock = $fileNamePreview . '.lock';
         while (true) {
             if (!file_exists($lock)) {
                 break;
             }
         }
         if (!file_exists($fileNamePreview) || !@filesize($fileNamePreview)) {
             $lock = $fileNamePreview . '.lock';
             if (!file_exists($lock)) {
                 @ignore_user_abort(1);
                 @set_time_limit(0);
                 @touch($lock);
                 $ffmpegPath = Q::ini('appini/catalog/ffmpegPath');
                 $ffmpegParameter = Q::ini('appini/catalog/ffmpegParameter');
                 //$command = "$ffmpegPath -i \"$fileName\" -y -ab 56 -ar 22050 -r 15 -b 500 -s 320x240 \"$fileNamePreview\"";
                 //$command = "$ffmpegPath -i \"$fileName\" -y -ab 56 -ar 22050 -r 15 -s 320x240 \"$fileNamePreview\"";
                 $command = "{$ffmpegPath} -i \"{$fileName}\" {$ffmpegParameter} \"{$fileNamePreview}\"";
                 //$command .= "&& $ffmpegPath -i \"$fileName\" -y -f image2 -ss 8 -t 0.011 -s 320x240 \"$fileNamePreview.jpg\"";
                 @exec($command);
                 @unlink($lock);
             }
         }
         $output = new QView_Output($file->title . '.' . $file->ext, 'video/x-flv');
         $output->addFile($fileNamePreview);
         return $output;
     } else {
         if ($file->type == 4) {
             if ($file->ext == 'txt') {
                 $handle = @fopen($fileName, 'r');
                 $data = @fread($handle, @filesize($fileName));
                 @fclose($handle);
                 return Helper_Util::encoding($data, 'utf-8');
             } else {
                 return '无法预览非文本文件(*.txt)格式';
             }
         } else {
             $output = new QView_Output($file->title);
             $output->addFile($fileName);
             if ($file->ext == 'jpg' || $file->ext == 'jpeg') {
                 $output->setMimeType('image/jpeg');
             }
             return $output;
         }
     }
 }
Beispiel #2
0
 条。 (用时 <?php 
echo isset($result) ? $result['time'] : 0;
?>
 秒)</span></p>

        <ul class="result">
            <?php 
if (isset($files)) {
    foreach ($files as $v) {
        ?>
            <li>
                <a class="title" target="_blank" href="<?php 
        echo url('admin::fileSearch/view', array('id' => $v->id));
        ?>
"><?php 
        echo Helper_Util::substr($v->title, 40);
        ?>
</a>
                <p>文件名:<?php 
        echo $v->name;
        ?>
;
                   文件类型:<?php 
        echo $v->ext;
        ?>
;
                   文件大小:<?php 
        echo $v->size_formatted;
        ?>
;                   
                   上传者:<?php 
Beispiel #3
0
                            <td class="lbl tr" nowrap="true">类型:</td><td><input type="text" readonly="true" value="<?php 
echo $file->type_formatted;
?>
" class="txt w350"/></td>
                        </tr>
                        <tr>
                            <td class="lbl tr" nowrap="true">文件名:</td><td><input type="text" readonly="true" value="<?php 
echo $file->name;
?>
" class="txt w350"/></td>
                            <td class="lbl tr" nowrap="true">文件类型:</td><td><input type="text" readonly="true" value="<?php 
echo $file->ext;
?>
" class="txt" style="width:138px;"/>
                                <span class="lbl tr">&nbsp;文件大小:</span><input type="text" readonly="true" value="<?php 
echo Helper_Util::formattedFileSize($file->size);
?>
" class="txt" style="width:130px;"/></td>
                        </tr>
                        <tr>
                            <td class="lbl tr" nowrap="true">上传者:</td><td><input type="text" readonly="true" value="<?php 
echo $file->upload_username;
?>
" class="txt w350"/></td>
                            <td class="lbl tr" nowrap="true">上传时间:</td><td><input type="text" readonly="true" value="<?php 
echo $file->upload_at_formatted;
?>
" class="txt w350"/></td>
                        </tr>
                        <tr>
                            <td class="lbl tr" nowrap="true">编目者:</td><td><input type="text" readonly="true" value="<?php