这是我的控制器..
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' => 'AdminController@getFile'));
Route::post('/file', array('as' => 'postUpload','uses'=>'AdminController@postUpload'));
我试图将Excel CSV文件导入数据库,但是当我点击导入按钮时,它说控制器方法未找到,请帮帮我.. 提前谢谢
答案 0 :(得分:0)
如果您使用的是Laravel 5,请尝试:
<form action="{!!route('postUpload')!!}" method="post" enctype="multipart/form-data">