欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

关于uploadify插件在火狐浏览器的兼容问题!!!

程序员文章站 2022-05-13 19:46:14
...
uploadify 插件在谷歌上一切都ok
但是在火狐上一直报302错误
网上找了一大把资料 模糊的意思是在火狐上服务器端要判断session的值 因为前端没有发过来 所以会验证失败 导致重定向 可是具体如何操作的?

针对PHP的具体办法是什么?
求回答相关话题,无关紧要或没意义的回帖我会踩你,谢谢!

/*
以下是客户端代码
*/

____________分割线______________
/*
以下是服务端代码
*/
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;
            }
        }
    }

回复内容:

uploadify 插件在谷歌上一切都ok
但是在火狐上一直报302错误
网上找了一大把资料 模糊的意思是在火狐上服务器端要判断session的值 因为前端没有发过来 所以会验证失败 导致重定向 可是具体如何操作的?

针对PHP的具体办法是什么?
求回答相关话题,无关紧要或没意义的回帖我会踩你,谢谢!

/*
以下是客户端代码
*/

____________分割线______________
/*
以下是服务端代码
*/
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;
            }
        }
    }

首先,我是JAVA开发,但是这个问题本质跟语言无关

问题是session丢失的问题,那么你需要在请求的时候带上JSONID传过去,就像用户浏览器禁用cookie的url重写一样。

相关标签: php jquery ci