2012-02-15 5 views
0
//uploading product movie or image? 
     if($this->input->post('upload_360') == "Upload") { 
      $config['upload_path'] = './media/images/products/360s'; 
      $config['allowed_types'] = 'swf'; 
      $this->load->library('upload', $config); 
      $this->upload->initialize($config); 
      if (!$this->upload->do_upload('film')) { 
       $this->data['product_error'] = $this->upload->display_errors(); 
       $this->template->build('/admin/products/create', $this->data); 
      } else { 
       $this->data['data_360'] = $this->upload->data(); 
       $this->session->set_userdata(array('360_film' => $this->data['data_360'])); 
       $this->template->build('/admin/products/create', $this->data); 
      } 
      $this->session->set_userdata(array('advantages' => $this->input->post('product_advantages'))); 
      $this->data['session_advantages'] = $this->session->userdata('advantages'); 
     } 
     //upload the product image, if successful the user will be 
     //notified if the image is too high or wide, and will be offered, 
     //the chance to crop the image. All cropping takes place in the media 
     //controller. 
     if($this->input->post('product_image') == "Upload") { 
      $config['upload_path'] = './media/images/products/'; 
      $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
      $this->load->library('upload', $config); 
      $this->upload->initialize($config); 
      if (!$this->upload->do_upload('image_upload')) { 
       //die("!"); 
       $this->data['image_error'] = $this->upload->display_errors(); 
       $this->template->build('/admin/products/create', $this->data); 
      } else { 
       $this->data['image_data'] = $this->upload->data(); 
       $this->session->set_userdata(array('image' => $this->data['image_data'])); 
       $this->data['session_image'] = $this->session->userdata('image'); 
       $this->template->build('/admin/products/create', $this->data); 
      } 
      $this->session->set_userdata(array('advantages' => $this->input->post('product_advantages'))); 
      $this->data['session_advantages'] = $this->session->userdata('advantages'); 
     } 

     if($this->input->post('screenshot_upload') == "Upload") { 
      $config['upload_path'] = './media/images/products/360s/screenshots/'; 
      $config['allowed_types'] = 'gif|jpg|jpeg|png'; 
      $this->load->library('upload', $config); 
      $this->upload->initialize($config); 
      if (!$this->upload->do_upload('screenshot')) { 
       //die("!"); 
       $this->data['screenshot_error'] = $this->upload->display_errors(); 
       $this->template->build('/admin/products/create', $this->data); 
      } else { 
       $this->data['screenshot_data'] = $this->upload->data(); 
       $this->session->set_userdata(array('screenshot' => $this->data['screenshot_data'])); 
       $this->data['session_screenshot'] = $this->session->userdata('screenshot'); 
       $this->template->build('/admin/products/create', $this->data); 
      } 
      $this->session->set_userdata(array('advantages' => $this->input->post('product_advantages'))); 
      $this->data['session_advantages'] = $this->session->userdata('advantages'); 
     } 

私のフォームでは、ユーザーがファイルを選択し、クリックするとどのボタンがクリックされたかによってアップロードボタンがクリックされ、アップロードデータがセッションに保存されます。データがセッションコードで設定されていない

セッションを使用してデータベースに保存するデータを取得すると、upload_360セッションが機能し、product_imageセッションはうまく動作しますが、screenshot_uploadセッションはif文(コードの3番目)セッションのその部分が空であれば、コードの外でアクセスしてみてください。

これには理由がありますか?

+0

間違いはありますか?どのタイプのセッションを使用していますか。コードニッタークッキー、データベース、ネイティブセッション、またはphpsession? – Henesnarfel

+0

どのブラウザをお使いですか? –

答えて

0

なぜデータをセッションに保存してからdbに挿入するのですか?

のみデータの4キロバイトを保持することができますクッキー...

が、screenshot_uploadセッションは、if文(コード内の3番目の1)で、私がしようとする場合にのみデータを持っているし、コードの外にそれをacccessセッションのその部分は空ですか?

私はあなたの質問のその部分を理解していません。第3のif文を使用している場合にのみデータがあることを意味しますか?すなわち、product_imageまたは360_upload`ではなく、screenshot_uploadを実行しようとするときだけですか?もしそうなら、それはクッキーの大きさの制限に言及するかもしれません。

代わりの

$this->session->set_userdata(array('screenshot' => $this->data['screenshot_data'])); 
$this->data['session_screenshot'] = $this->session->userdata('screenshot'); 

なぜないあなた

$this->uploads_model->insert_screenshot_data($this->data['screenshot_data']);//send screenshot upload_data to model to be inserted into db 
$this->data['screenshot_data'] = $this->data['screenshot_data'];//if you want to pass screenshot upload_data to template/view 

?あなたは、セッションを設定する前に、ユーザーに出力を送信しているように見えます

0

(私はカスタムコードでの$ this - >テンプレート - >ビルド、からこれを推測しています。)

セッション、ヘッダのような何か(何か)が出力された後は変更できません。これは、セッション自体がヘッダーで送信されるためです。

関連する問題