2016-03-26 24 views
1

這裏是我的控制器..NotFoundHttpException:控制方式未找到

public function postUpload() { 
     if (Input::hasFile('file')) { 

      $files = Input::file('file'); 
      $file = fopen($files, "r"); 
      while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { 
       $insert = ImportModel::create(array('company_name' => $emapData[0], 
          'contact_person' => $emapData[1], 
          'state' => $emapData[2], 
          'city' => $emapData[3], 
          'country' => $emapData[4], 
          'email_address' => $emapData[5], 
          'category' => $emapData[6] 
       )); 
      }//WHILE BODY 
      //foreach($insert as $emapData => $values){ 
      // echo $emapData.'<br>'; 
      //} 
      if ($insert) { 

       echo "done"; 
      }//INNER IF BODY 
     }//IF BODY 
    }//POST UPLOAD FUNCTION 

這裏是我的Route.php

Route::get('/file', array('as' => 'getfile','uses' => '[email protected]')); 

Route::post('/file', array('as' => 'postUpload','uses'=>'[email protected]')); 

我試圖導入Excel的CSV文件到數據庫,但是當我打進口按鈕它說控制器方法沒有找到,請幫助我.. 在此先感謝

+0

這是我的形式動作 – Sherry

+0

<形式行動= 「{{URL ::路線( 'postUpload')}}」 方法= 「POST」 ENCTYPE = 「多部分/格式數據」> – Sherry

+0

如果刪除method =「post」,所以它不會顯示這個錯誤控制器方法未找到,如果我將其更改爲method =「get」,那麼它不會顯示錯誤,但不工作 – Sherry

回答

0

如果您使用Laravel 5,請嘗試:

<form action="{!!route('postUpload')!!}" method="post" enctype="multipart/form-data"> 
+0

不工作,試圖.. @Digitlimit我測試這些代碼在另一個項目上,我做了新鮮的,在該項目上相同的代碼工作..但在其他項目,我只是嵌入這些代碼,並沒有工作..我告訴你我的完整admincontroller – Sherry

+0

你還有其他路線嗎?它可能會與另一條路線衝突 – Digitlimit

+0

我可以看到您的routes.php – Digitlimit