hello,
I integrate SWFupload to my site which basic on Zend Framework, It ok in IE7, but something wrong with firefox. I used the applicationdemo, in firefox, it fine to upload the image files but can't creat the thumbnail, because the session which save the thumbnail image can't pass to the thumbnailAction . Here is the code.
uploadimgController.php
function uploadAction()
{
$params = $this->_request->getParams();
if (isset($params['sid'])) {
session_id($params['sid']);
}
$imgSession = new Zend_Session_Namespace('img');
......
move_uploaded_file($_FILES["Filedata"]["tmp_name"],$img_dir.$_FILES["Filedata"]["name"]); // it's successful.
......
$imgSession->file_info[$file_id] = $imagevariable;
......
}
function thumbnailAction()
{
$params = $this->_request->getParams();
if (isset($params['sid'])) {
session_id($params['sid']);
}
$imgSession = new Zend_Session_Namespace('img');
......
echo $imgSession->file_info[$image_id];
......
}
the img namespace is empty, the session is not effect. Maybe the session_id($params['sid']) can't call back the old session in zend framework...
How deal with the session ?
December 5, 2008 - 9:24am
Hi
Try this:
When you create swfupload object in JavaScript code set parameter
debug : true
and see what POST data sending to server
December 5, 2008 - 10:05am
array(6) {
["controller"]=>
string(9) "uploadimg"
["action"]=>
string(6) "upload"
["module"]=>
string(7) "default"
["Filename"]=>
string(13) "test (18).JPG"
["video_id"]=>
string(2) "13"
["Upload"]=>
string(12) "Submit Query"
}
what is the _POST["Upload"]?
the POST is the indexAction to the uploadAction , the thumbnail session is defined in uploadAction and called in thumbnailAction.
I var_dump the session in indexAction , it's
array(1) { ["file_info"]=> array(0) { } } .
December 5, 2008 - 10:24am
This is likely related to the known Cookie Bug. Most sessions are maintained using a cookie. The Flash Player does not send the cookies in FireFox (or other browsers that use the same plugin. IE works.). This is lightly documented and a Cookie Bug demo is provided showing that Flash always sends the IE cookies even in Firefox.
The work-around is to add your session ID to a post_param and then manually restore the session on the server. This can get complicated when using a Framework. You'll have to refer to your Framework's documentation on how to do this.
December 5, 2008 - 10:52am
Thank you so much.
I know that it is the Cookie Bug. But I am poor in zend framework and it seems no help in the zend framework document about the zend session. Also it is base on PHP. I post the session id to server
(post_params: {"sid": "<?php echo session_id(); ?>"} )
and call both in uploadAction and thumbnailAction ,
session_id($params['sid']);
but it seems not work as I want...
December 7, 2008 - 12:19am
Through the POST data, it is not succeed to pass the session id because I wrote two "post_params :" sentence. But when I fixed it, after upload the image files, my user got logout although i do "session_id($params['sid']);" in uploadAction and thumbnailAction.
It is Zend Framework , it called session start in the index.php and Sustained all the time. When do "session_id($params['sid']);", it is a new session which have no the information of the user. So it better to manual to write the user date into session (Zend_Auth) in both uploadAction and thumbnailAction.
February 26, 2009 - 2:48pm
Could you explain, how to resolve it, please?
April 2, 2009 - 3:48pm
Hello,
I've solved this issue using a bit of a hack.
I've created an early running controller plugin which executes the following statement when a swfupload post request is sent to my controller/action for managing uploads. if not using Zend Framework just make sure to execute the statement before the session_start() call.
$_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];This obviously has some security ramifications, but I've tried to reduced the risk by limiting this behavior to a single controller/action and only allowing the flash user agent to trigger this behavior.
yes - security through obscurity. I wish Adobe/Firefox would resolve the real problem once and for all.
January 22, 2010 - 11:09pm
Hi
If I use a physical php file, lets say upload.php file it works, but if I copy the script into controller and specify the url as index/upload(controllername/actionname), it doesn't work in my zend framework application.
Please help me
January 24, 2010 - 7:18pm
Please don't cross post.