In your view where you initialise SWFUpload (adapt as necessary)
<script type="text/javascript"
>
var
upload_url = '<?php echo $html->url('
/uploads/upload/
'.$session->id()) ?>'
;
</script>
The above code includes the current session id as part of the URL and so the beforeFilter callback can revive your session information.
/app/controllers/uploads_controller.php
<?php
class
UploadsController extends
AppController {
var
$name
= 'Uploads'
;
var
$components
= array
(
'SwfUpload'
)
;
var
$helpers
= array
(
'Html'
, 'Javascript'
)
;
function
beforeFilter(
)
{
if
(
$this
->action
== 'upload'
)
{
$this
->Session
->id
(
$this
->params
[
'pass'
]
[
0
]
)
;
$this
->Session
->start
(
)
;
}
parent::beforeFilter
(
)
;
}
function
upload(
)
{
if
(
isset
(
$this
->params
[
'form'
]
[
'Filedata'
]
)
)
{
// process your upload in here
// and you can read from or write to the session
// as you would normally
}
}
}
?>
原文链接:
http://blogs.bigfish.tv/adam/2008/04/01/cakephp-12-sessions-and-swfupload/