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'] ?>');
}
});
});