在使用swfupload时出现2038错误

发布于 2021-11-14 21:00:42 字数 157 浏览 872 评论 5

我服务器使用的是nginx+apache+php nginx在前端代理后端apache。网站主要做的是教育网站,提供在线视频播放功能。视频由会员自己上传,使用的上传工具为swfupload,但现有遇到个问题。上会员在上传视频的时候总是出现2038错误,在网上查了相关的资料也按上面的做了相应的修改可是问题依然存在。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

千纸鹤带着心事 2021-11-19 14:02:53

你说的也有一定的道理,不过我看youku他上传比较稳定。我不知道这个是否可以在服务器上实现。

青萝楚歌 2021-11-19 11:01:25

上传限速,需要从上传的途径入手,基于Web传统模式是不太可能限制的了的。

如果要限速,就必须自己开发浏览器插件来实现。

中国的互联网环境,家用环境的宽带,上行基本上都很不高。

情栀口红 2021-11-19 10:39:06

嗯,谢谢你的提议。我去看一下这个插件。

柳若烟 2021-11-19 09:32:12

最好别用swfupload了,有xss漏洞,而且已经停止更新很多年。

推荐转用plupload,支持基于HTML5模式,很好的解决了手机平台的兼容性问题。而且他针对xss的bug修复过。

国外很多的CMS系统都转用plupload了,如Wordpress就是。

而且,plupload的核心库和事件机制,很简单,十分容易使用,也容易嵌入到别的JS框架中,如我尝试过嵌入到ExtJS中使用。

一人独醉 2021-11-17 13:21:46

这个我swfupload的主配置:

<script type="text/javascript">
	    var swfu;
		window.onload = function() {
			var settings = {
				flash_url : "http://www.gaixue.com/swfupload/swfupload.swf",
				flash9_url : "http://www.gaixue.com/swfupload/swfupload_fp9.swf",
				file_post_name : "videofile",
				post_params: {
				    "PHPSESSID": "<?php echo session_id(); ?>"
					
				},
				upload_url: "http://www.gaixue.com/uploadvideo",
				file_size_limit : "500 MB",
				file_types : "*.swf;*.mpg;*.wmv;*.asf;*.3gp;*.rm;*.mov;*.asx;*.f4v;*.rmvb;*.avi;*.mp4;*.flv",
				file_types_description : "Video Files",
				file_upload_limit : 1,
				file_queue_limit : 1,

				debug: false,

				// Button settings
				//button_image_url: "http://www.gaixue.com/images/upload_video_bg.jpg",
				//button_text: "<b>上传视频</b>",
				button_width: "105",
				button_height: "36",
				button_placeholder_id: "spanButtonPlaceHolder",
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				moving_average_history_size: 40,
				
				// The event handler functions are defined in handlers.js
				swfupload_preload_handler : preLoad,
				swfupload_load_failed_handler : loadFailed,
				file_queued_handler : fileQueued,
				file_dialog_complete_handler: fileDialogComplete,
				file_queue_error_handler : fileQueueError,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				upload_error_handler : uploadError,
				
				custom_settings : {
				    uploadstatus : document.getElementById("uploadstatus"),
					uploadbutton : document.getElementById("uploadbutton"),
					fileName : document.getElementById("filename"),
					fileSize : document.getElementById("filesize"), //文件大小
					loadingBar : document.getElementById("loading"), //进度条
					cancelBt : document.getElementById("cancelBt"), //取消上传
					videoUrl : document.getElementById("tmp_video_url"), //视频上传成功后地址
					progressTarget : document.getElementById("progressBox"),
					movefileInfo : document.getElementById("movefile"),
					
					tdCurrentSpeed : document.getElementById("CurrentSpeed"), //当前上传速度
					tdTimeRemaining : document.getElementById("TimeRemaining"), //剩余时间
					tdPercentUploaded : document.getElementById("PercentUploaded") //上传百分比
				}
			};
			swfu = new SWFUpload(settings);
		};
	</script>

这个是我的handlers.js

function preLoad() {
	if (!this.support.loading) {
		alert("You need the Flash Player 9.028 or above to use SWFUpload.");
		return false;
	}
}
function loadFailed() {
	alert("Something went wrong while loading SWFUpload. If this were a real application we'd clean up and then give you an alternative");
}

function fileQueued(file) {
	try {
		this.customSettings.uploadstatus.style.display = 'block'; //显示进度框
		this.customSettings.fileName.innerHTML = file.name;
		//this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;
		//获取待上传的文件大小
		this.customSettings.fileSize.innerHTML = formatFileSize(file.size);
	} catch (ex) {
		this.debug(ex);
	}

}

function fileDialogComplete() {
	this.startUpload();
}

function fileQueueError(file, errorCode, message) {
	try {
		var errorName = "";
		if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
			errorName = "You have attempted to queue too many files.";
		}

		if (errorName !== "") {
			alert(errorName);
			return;
		}

		switch (errorCode) {
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
			alert('0字节');
			break;
		case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
			alert('文件太大了,请上传小于500M的视频文件');
			break;
		case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
		   alert("不允许的视频格式rn支持(*.swf;*.mpg;*.wmv;*.f4v;*.rmvb;*.avi;*.mp4;*.flv)");
		   break;
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
		default:
			alert(message);
			break;
		}

	} catch (ex) {
		this.debug(ex);
	}

}

function uploadStart(file) {
	try {
		this.customSettings.progressCount = 0;
		updateDisplay.call(this, file);
	}
	catch (ex) {
		this.debug(ex);
	}
	
}

function uploadProgress(file, bytesLoaded, bytesTotal) {
	try {
		this.customSettings.progressCount++;
		var bar = Math.ceil((bytesLoaded / bytesTotal) * 100);
		this.customSettings.loadingBar.style.width = (bar-1)+"%";
		updateDisplay.call(this, file);
		if((bar-1)==99){
			this.customSettings.movefileInfo.innerHTML = ",正在移动请稍后";
			this.customSettings.tdPercentUploaded.innerHTML = "99.00 %";
		}
		
	} catch (ex) {
		this.debug(ex);
	}
	
}

function uploadSuccess(file, serverData) {
	try {
		var serverInfo = eval('('+serverData+')');
		//var progress = new FileProgress(file, this.customSettings.progressTarget);
        //progress.setComplete();
		if(serverInfo.status==1){
			var uploadfile = serverInfo.info;
			/*for(var i=0;i<=uploadfile.length;i++){
				this.customSettings.videoUrl.value = '/'+uploadfile[i].savepath+uploadfile[i].savename;
			}*/
			this.customSettings.videoUrl.value = uploadfile[0].savepath+uploadfile[0].savename;
			//alert(serverInfo.data);
			//progress.setStatus("ok");
		}
		else{
			alert(serverInfo.data+"["+serverInfo.info+"]");
			//progress.setStatus(serverInfo.data+"["+serverInfo.info+"]");
		}
		updateDisplay.call(this, file);
		//progress.toggleCancel(false);
	} catch (ex) {
		this.debug(ex);
	}
}

function uploadComplete(file) {
	//this.customSettings.tdFilesQueued.innerHTML = this.getStats().files_queued;
	//this.customSettings.tdFilesUploaded.innerHTML = this.getStats().successful_uploads;
	//this.customSettings.tdErrors.innerHTML = this.getStats().upload_errors;
	
	this.customSettings.loadingBar.style.width = 100+"%";
	this.customSettings.tdPercentUploaded.innerHTML = "100.00 %";
	this.customSettings.movefileInfo.innerHTML = "";
	this.customSettings.cancelBt.style.display = "none";
	if(!this.getStats().upload_errors) {alert('上传成功');}
}

function uploadError(file, errorCode, message){
	var progress;
	try {
		switch (errorCode) {
		case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
			try {
				progress = new FileProgress(file,  this.customSettings.progressTarget);
				progress.setCancelled();
				progress.setStatus("Cancelled");
				progress.toggleCancel(false);
			}
			catch (ex1) {
				this.debug(ex1);
			}
			break;
		case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
			try {
				progress = new FileProgress(file,  this.customSettings.progressTarget);
				progress.setCancelled();
				progress.setStatus("Stopped");
				progress.toggleCancel(true);
			}
			catch (ex2) {
				this.debug(ex2);
			}
		case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
			alert('上传的文件太大了');
			break;
		default:
			alert(message);
			break;
		}
	} catch (ex3) {
		this.debug(ex3);
	}
    //出现错误时隐藏上传进度条
	this.customSettings.uploadstatus.style.display = 'none';
}

function updateDisplay(file) {
	this.customSettings.tdCurrentSpeed.innerHTML = SWFUpload.speed.formatBPS(file.currentSpeed);
	//this.customSettings.tdAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.averageSpeed);
	//this.customSettings.tdMovingAverageSpeed.innerHTML = SWFUpload.speed.formatBPS(file.movingAverageSpeed);
	this.customSettings.tdTimeRemaining.innerHTML = SWFUpload.speed.formatTime(file.timeRemaining);
	//this.customSettings.tdTimeElapsed.innerHTML = SWFUpload.speed.formatTime(file.timeElapsed);
	this.customSettings.tdPercentUploaded.innerHTML = SWFUpload.speed.formatPercent(file.percentUploaded);
	//this.customSettings.tdSizeUploaded.innerHTML = SWFUpload.speed.formatBytes(file.sizeUploaded);
	//this.customSettings.tdProgressEventCount.innerHTML = this.customSettings.progressCount;
}

//格式化文件大小
function formatFileSize(value, record){
	if(null==value||value==''){
		return "0 Bytes";
	}
	var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
	var index=0;
	var srcsize = parseFloat(value);
	var quotient = srcsize;
	while(quotient>1024){
		index +=1;
		quotient=quotient/1024;
	}
	return roundFun(quotient,2)+" "+unitArr[index];
}
//四舍五入保留指定小数位
function  roundFun(numberRound,roundDigit) {
	if(numberRound>=0) {
		var  tempNumber = parseInt((numberRound*Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
		return tempNumber;
	}else{
		numberRound1 =- numberRound;
		var tempNumber = parseInt((numberRound1*Math.pow(10,roundDigit)+0.5))/Math.pow(10,roundDigit);
		return  -tempNumber;
	}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文