uploadify 插件在谷歌上一切都ok
但是在火狐上一直报302错误
网上找了一大把资料 模糊的意思是在火狐上服务器端要判断session的值 因为前端没有发过来 所以会验证失败 导致重定向 可是具体如何操作的?
针对PHP的具体办法是什么?
求回答相关话题,无关紧要或没意义的回帖我会踩你,谢谢!
/*
以下是客户端代码
*/
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5('unique_salt' . $timestamp);?>'
},
'buttonText':'上传文件',
'fileTypeExts' : '*.doc;*.docx;*.pdf;',
'swf' : '<?php echo base_url("js/uploadify/uploadify.swf");?>',
'uploader' : '<?php echo base_url('module/files/main/uploadify?type=1')?>',
'onUploadSuccess' : function(file, data, response) {
alert(data);
},
});
});
____________分割线______________
/*
以下是服务端代码
*/
public function uploadify() {
$type = $_GET['type'];
$targetPath = './uploads/uploadify_file';
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
if (!file_exists($targetPath)) {
@mkdir($targetPath);
chmod($targetPath, 0777);
}
$file_name = $_FILES['Filedata']['name'];
$hz = explode(".",$_FILES['Filedata']['name']);
$targetFile = rtrim($targetPath,'/') . '/' . md5(time()).".".$hz[1];
// Validate the file type
$fileTypes = array('doc','docx','pdf'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
if(move_uploaded_file($tempFile,$targetFile)){
$file_message = array(
'file_name'=>$file_name,
'file_creat_time'=>time(),
'file_url'=> $targetFile,
'file_type'=>$type
);
$res = $this->files_Model->insert($file_message);
if (!$res) {
echo '文件'.$file_message['name'].'保存失败';
return FALSE;
}else{
echo '上传成功';
return TRUE;
}
}else{
echo '啊哦!文件移动失败了,请检查文件路径';
return FALSE;
}
} else {
echo '文件类型不匹配哈!';
return FALSE;
}
}
}