1
我在CakePHP中使用jquery uploadify,并且我遇到了$ _SESSION的问题,因为我有下面的动作接收用户ID $ this-> request-> params [ 'named'] ['uid']问题是,启用uploadify的操作会执行两次,但第二个数据$ this-> request-> params ['named'] ['uid']会丢失。Uploadify正在执行的动作运行两次
以下是为了更好理解而简化的代码。
FilesController.php /指数**运行两次
public function index() {
$id = $this->request->params['named']['uid'];
$us = $this->User->findById($id)['User'];
$dir = UPLOAD_DIR . $us['id'] . '/';
CakeSession::write('Files.atual', $dir);
$this->set('u', $us);
//$this->autoRender = false;
}
查看/元/ up.ctp //启用Uploadify
<?php $timestamp = time(); ?>
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp; ?>',
'token' : '<?php echo md5('unique_salt' . $timestamp); ?>'
},
'swf' : '<?= $this->request->webroot; ?>uploadify.swf',
'preventCaching' : false,
'uploader' : '<?= $this->request->webroot; ?>uploadify.php?session_id=<?php echo(session_id()); ?>',
'buttonClass' : 'button icon-paperclip',
'buttonText' : 'Enviar Arquivos',
'onUploadSuccess' : function(file, data, response) {
$('.files-icons').load('<?= $this->request->webroot; ?>files/reload/<?= $u['id'] ?>');
}
});
});