php - 关于uploadify插件在火狐浏览器的兼容问题!!!
迷茫
迷茫 2017-04-10 17:08:48
[PHP讨论组]

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

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

/*
以下是客户端代码
*/
<input id="file_upload" name="file_upload" type="file" multiple="true"> 

<script type="text/javascript">
        <?php $timestamp = time();?>
        $(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);
                },
            });
        });
    </script>
____________分割线______________
/*
以下是服务端代码
*/
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;
            }
        }
    }
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(1)
大家讲道理

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

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

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号