php+Uploadify在win7下安装配置好了,也可以正常运行,但在linux下无法上传
PHP这里我用的是YII框架,应该没什么影响
<br />/*<br /> Uploadify 后台处理方法<br /> */<br /> public function actionuploadify(){<br /> <br /> //设置上传目录<br /> $path = "./uplode/video/";<br /> //这里$_FILES为空<br /> if (!empty($_FILES)) {<br /> <br /> //得到上传的临时文件流<br /> $tempFile = $_FILES['Filedata']['tmp_name'];<br /> <br /> //允许的文件后缀<br /> $fileTypes = array('avi','rmvb','mpg','wav');<br /> <br /> //得到文件原名<br /> $fileName = iconv("UTF-8","GB2312",$_FILES["Filedata"]["name"]);<br /> $fileParts = pathinfo($_FILES['Filedata']['name']);<br /> <br /> //接受动态传值<br /> $files=$_POST['typeCode'];<br /> <br /> //最后保存服务器地址<br /> if(!is_dir($path))<br /> mkdir($path);<br /> <br /> <br /> //判断singerInfo文件是否存在且不为空 <br /> $this->getSingFile();<br /> <br /><br /> if (move_uploaded_file($tempFile, $path.$fileName)){<br /> $myfile = explode(".",$fileName);<br /> <br /> $sql = $this->getfile($myfile[0],1);<br /><br /> if ($sql){<br /> <br /> //songandSinger文档插入<br /> $songSingerFile = "./uplode/image/songSinger.txt";<br /> $this->getSongFile($myfile[0],$songSingerFile,"dSongAndSinger","kSingerID");<br /> <br /> //songandType文档插入<br /> $songTypeFile = "./uplode/image/songType.txt";<br /> $this->getSongFile($myfile[0],$songTypeFile,"dSongAndType","kSongTypeID");<br /> <br /> //songandStyle文档插入<br /> $songStyleFile = "./uplode/image/songStyle.txt";<br /> $this->getSongFile($myfile[0],$songStyleFile,"dSongAndStyle","kSongStyleID");<br /><br /> echo $fileName."文件上传成功,数据上传成功!";<br /> <br /> }else{<br /> echo $fileName."文件上传成功,数据上传失败!";<br /> }<br /> //<br /><br /> }else{<br /> echo $fileName."上传失败!";<br /> }<br /> <br /> }<br /><br /> }<br />
<a href="javascript:$('#file_upload').uploadify('settings', 'formData', {'typeCode':document.getElementById('id_file').value});$('#file_upload').uploadify('upload','*')">上传</a>
<br /><script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-1.7.2.min.js"></script><br /><script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.uploadify-3.1.min.js"></script><br /><br /><link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/uploadify.css"/><br /><script type="text/javascript"><br />var img_id_upload=new Array();//初始化数组,存储已经上传的图片名<br />var i=0;//初始化数组下标<br />$(function() {<br /> $('#file_upload').uploadify({<br /> 'auto' : false,//关闭自动上传<br /> 'removeTimeout' : 600,//文件队列上传完成1秒后删除<br /> 'swf' : '<?php echo Yii::app()->request->baseUrl; ?>/js/uploadify.swf',<br /> 'uploader' : 'uploadify',//uploadify.php<br /> 'method' : 'post',//方法,服务端可以用$_POST数组获取数据<br /> 'buttonText' : '选择文件',//设置按钮文本<br /> 'multi' : true,//允许同时上传多张图片<br /> 'uploadLimit' : 10,//一次最多只允许上传10张图片<br /> 'fileTypeDesc' : 'Video Files',//只允许上传图像<br /> 'fileTypeExts' : '*.rmvb; *.mpg; *.wav',//限制允许上传的图片后缀<br /> 'fileSizeLimit' : '2GB',//限制上传的图片不得超过200KB <br /> 'onUploadSuccess' : function(file, data, response) {//每次成功上传后执行的回调函数,从服务端返回数据到前端<br /> img_id_upload[i]=data;<br /> i++;<br /> alert(data);<br /> <br /> // window.location.reload();<br /> },<br /> 'onQueueComplete' : function(queueData) {<br /> $("#result").html('');<br /> //上传队列全部完成后执行的回调函数<br /> // if(img_id_upload.length>0)<br /> // alert('成功上传的文件有:'+encodeURIComponent(img_id_upload));<br /> } <br /> // Put your options here<br /> });<br />});<br /></script><br />