2

我在我的 php 网站中集成了 uploadify 3.1。

问题:我的uploadify 脚本适用于较小的视频。视频文件上传到目标文件夹并存储到数据库中。

1) 对于 50 MB 以下的视频文件 - 视频上传很好,但在完成 100% 上传后,虽然视频已上传到目标文件夹并且信息也存储到数据库中,但它会给出 302 错误。

2) 对于 50 MB 以上的视频文件 - 视频上传状态显示视频已上传 100%。在进度条中获得 100% 上传状态后,视频不会上传到目标文件夹,也不会存储到数据库中。

请帮助解决这些问题。我试图提供尽可能多的信息。

下面的东西是在 IIS 服务器上设置的,所以这不是问题。

php 5.2.7
mysql
max_execution_time = 10800 seconds
max_input_time = 10800 seconds
memory_limit = 512M
post_max_size = 512M
upload_max_filesize = 512M
Fast CGI Timeout = 3600 seconds

下面是网站结构

admin (folder)
     video/video_add.php (upload page location inside admin folder)
     video/video_add_p.php (upload programming where file is being uploaded and stored into database)
data (folder)
     video (video files will be stored inside this folder)

以下文件包含在 video_add.php 页面上

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.uploadify-3.1.min.js" type="text/javascript"></script>

以下是 video_add.php 页面上的上传设置

<script type="text/javascript">
<?php $timestamp = time();?>
$(function() {
    $('#file_upload').uploadify({
        'auto'          : true,
        'buttonText'        : 'SELECT AND UPLOAD VIDEO',
        'checkExisting'     : './check-exists.php',
        'fileSizeLimit'     : '200MB',
        'fileTypeDesc'      : 'Video Files',
        'fileTypeExts'      : '*.flv; *.mp4; *.mpg; *.mpeg; *.wmv; *.FLV; *.MP4; *.MPG; *.MPEG; *.WMV;', 
        'formData'          : {
            'timestamp'     : '<?php echo $timestamp;?>',
            'token'         : '<?php echo md5('unique_salt' . $timestamp);?>',
            'pkid'          : '<?php echo $int_pkid;?>',
             },
        'method'            : 'post',
        'multi'             : false,
        'progressData'      : 'speed',
        'removeCompleted'   : false,
        'swf'               : 'uploadify.swf',
        'uploader'          : './video_add_p.php',
        'uploadLimit'       : 1,
        'width'             : 250,
        'onSelect'          : function() { 
                                if(trim(txt_title.value)=="")
                                {
                                    alert("Please enter video name.");
                                    txt_title.focus();
                                    $('#file_upload').uploadify('cancel'); 
                                    return false;
                                }
                              },
        'onSelectError'     : function() { alert('The file returned an error and was not added to the queue.');},
        'onUploadStart'     : function() { $("#file_upload").uploadify('settings', 'formData', {'txt_title':  $('#txt_title').val()}); },
        'onUploadComplete'  : function() { location.reload(true); },
    });
});

下面是选择视频文件的输入按钮

<input type="text" id="txt_title" name="txt_title" size="90">
<input type="file" id="file_upload" name="file_upload" placeholder="Select your file to upload">

下面是video_add_p.php编程上传视频

$targetFolder = "../../data/video/"; // Relative to the root
$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $targetFolder;
$targetFileExt=GetExtension($_FILES['Filedata']['name']);
$targetFileName = "video_".$int_pkid."_".date("ymdhis").".".$targetFileExt;;
$targetFile = rtrim($targetPath,'/') . '/' . $targetFileName;

// Validate the file type
$fileTypes = array('flv','mp4','mpg','mpeg','wmv','FLV','MP4','MPG','MPEG','WMV'); 

    // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);

if (in_array($fileParts['extension'],$fileTypes)) {
    set_time_limit(0);
    move_uploaded_file($tempFile,$targetFile);
    echo '1';
} 
else { echo 'Invalid file type.'; }
}

-- Here script is written to store uploaded video file data into mysql database. --
4

1 回答 1

0

试着用这种格式写你的尺寸......希望它对你有用

'fileSizeLimit': 20971345,
于 2013-03-11T07:21:08.227 回答