2013-06-02 7 views
5

私はphpを使ってウィザードを構築しましたが、フォームの1つでは、Codeigniterを使用して、フォームがjquery submit()でサブミットされたかどうかを確認するには

私はすでにすべてを構築しましたが、唯一の問題は、if文の1つで、フォームがjqueryのsubmit()メソッドを使用して送信された場合です。

ここでは、ユーザーがイメージを選択した後にjqueryでフォームを送信するコードを示します。

var initUpload = function(){ 
    $('.filebutton').change(function(e){ 
     $("form").submit(); 
    }); 
}; 

これは私のif文の見た目です。

if($this->input->post('back')){ 

    //Tells me that the user clicked on the back button, and to go back 1 step in the wizard.  

}else if(???){ 

    //This is where I would like to say: if form was submitted with jquery.  

}else{ 

    //Else the user just clicked "next" and to continue normally. 

} 

私はすでに知っているもの:

$this->input->post('back')を使用して、フォームがBACKのvalueとボタンを使用して提出された場合、私は確認することができます。私はvar_dumped $this->input->post()でしたが、入力フィールドの値だけを返します。

+1

で見てさ'var_dump($ _ FILES)'にする必要があります –

+0

@dianuj - 私が探しているものです。私は 'else if($ _ FILES ['userfile'] ['name'])'と答えることができました。 – Kolby

+0

私の更新された答えは、 'CI'のライブラリを使ってファイルをアップロードするのに役立ちます –

答えて

4

私は答えとして私のコメントを投稿することが要求された上記のコメントのようにので、ここであなたはここで

if($this->input->post('back')){ 

//Tells me that the user clicked on the back button, and to go back 1 step in the wizard.  

}else if($_FILES['your_image_filed_name']){ 

//This is where I would like to say: if form was submitted with jquery. 
//you can use codeigniter's built in Upload libraray which v easy  

}else{ 

//Else the user just clicked "next" and to continue normally. 

} 

を行くuploadコードは `image`詳細あなたを取得するには

$config_logo_image = array(
    'allowed_types' => 'jpg|jpeg|gif|png', 
    'upload_path' => UPLOAD_PATH,//root path for image 
    'max_size' => 2000, 
    ); 
$this->load->library('upload', $config_logo_image);      
if($this->upload->do_upload('your_image_filed_name')){ 

$logo_image_data = $this->upload->data(); 

} 
関連する問題