2

jshelperでファイルをアップロードしようとしています。

私からしてみれば:

<?php echo $this->Form->create('Form', array(
    'inputDefaults' => array(
    'format' => array('before', 'error', 'label', 'between', 'input', 'after'),),
    'enctype' => 'multipart/form-data'
)); 
echo $this->Form->input('Form.file', array('type' => 'file', 'id'=>'file'));
$this->Js->get('#file')->event(
    'update',
    $this->Js->request(
        array('controller' => 'ControllerForm','action' => 'actionForm'),
        array(
        'async' => true, 
        'method' => 'post', 
        'dataExpression'=>true,
        'data'=> $this->Js->serializeForm(array(
            'isForm' => false,
            'inline' => true,
            ))
        )
));
echo $this->Js->writeBuffer();
echo $this->Form->end(); 
?>

私のコントローラーで:

public function actionForm(){
    debugger::dump($this->data);
}

ただし、debugger::dump空の配列を出力します。

4

1 に答える 1

0

私が知っているように、ajaxを使用してファイルを送信することはできません(ChromeにxhrRequestObject2を含めます)。最初にサーバー側で、post data instanted debug($_FILES) をチェックしますが、私が書いたようにそれは空です。古き良きiframeを使用してサーバーにデータを送信します。

于 2013-10-08T14:21:18.810 に答える