我在我的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页面上的uploadify设置
<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. --
答案 0 :(得分:0)
尝试用这种格式写你的尺寸......希望它可能适用于你
'fileSizeLimit': 20971345,