【问题标题】:Uploadify and Codeigniter FrameworkUploadify 和 Codeigniter 框架
【发布时间】:2012-01-07 18:44:25
【问题描述】:

我在使用 uploadify (http://www.uploadify.com/) 和 Codeigniter 框架 (http://codeigniter.com) 时遇到问题。

请检查控制器部分:

function uploadFile()
    {
    require_once('class.upload.php');
if (!empty($_FILES)) {
         $uc = $this->session->userdata('username');
         //$_REQUEST['folder'] = "/pro/user/Dileepmt/pages/".$_REQUEST['folder']."/images/background";
         $_REQUEST['folder'] = $uc."/pro/user/".$uc."/pages".$_REQUEST['folder']."/images/background";
        $targetPath = $_SERVER['DOCUMENT_ROOT'] .$_REQUEST['folder']. '/';
        $pic_temp = random_string('alnum',10);

        $handle = new Upload($_FILES['Filedata']);
            if ($handle->uploaded) {
                $handle->file_src_name_body      = $pic_temp; // hard name
                $handle->file_overwrite          = true;
                $handle->file_auto_rename        = false;
                $handle->image_resize            = true;
                $handle->image_ratio_y           = true;
                $handle->image_x                 = ($handle->image_src_x < 400)?$handle->image_src_x:400;
                $handle->file_max_size           = '819200'; // max size
                $handle->Process($targetPath);
                $handle->clean(); 
                if ($handle->processed)
                    $json = array("result"      => 1, 
                                  "file"        => $_REQUEST['folder'].'/'.$handle->file_dst_name.'?'.time(),
                                  "imagewidth"  => $handle->image_dst_x,
                                  "imageheight" => $handle->image_dst_y
                                 );
                else
                    $json = array("result" => 0);

                $encoded = json_encode($json);
                echo $encoded;
                unset($encoded);    
            } 
            else { 
                $json = array("result" => 0);
                $encoded = json_encode($json);
                echo $encoded;
                unset($encoded);
            }
}


    }

Uploadify 有很多问题,但在这里我无法使用 Codeigniter 会话库检索会话数据。

$uc = $this->session->userdata('username');

 $_REQUEST['folder'] = $uc."/pro/user/pages".$_REQUEST['folder']."/images/background";

假设 username = >'myuser' 和 'folder' = >'myfolder'

所以$_REQUEST['folder'] 将是myuser/pro/user/pages/myfolder/images/background

但结果是/pro/user/pages/myfolder/images/background

我检查了 Codeigniter 会话没有问题,我可以使用会话库设置或检索数据。

【问题讨论】:

    标签: php javascript codeigniter upload uploadify


    【解决方案1】:

    Uploadify 使用 Flash。 Flash 与您的浏览器分开,不会发送任何会话 ID 或 cookie。您可以使用 uploadifies 'scriptData' 属性来发送会话 ID 或其他内容。我在 html 表单中生成一个上传 id 并将其发送给 uploadify。提交公式后,我从上传目录中收集文件并将它们连接到会话。

    【讨论】:

    • 我想设置FOLDER选项,这取决于会话数据。我认为改变scriptData很容易。文件夹路径就像/host/username/pages/images/background/file.ext
    猜你喜欢
    • 2012-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 2011-12-14
    • 2013-04-01
    相关资源
    最近更新 更多