을 나는 패키지>http://csv.thephpleague.com/정의되지 않은 오프셋 : 1 Laravel/PHP 업로드 CSV
을 사용하고 있습니다하지만이 정의되지 않은 오프셋지고있어 다음 CSV 업로드하고이 오류를 작동 않지만 이는 분명히 발생합니다, 1 업로드 할 때 나는 클라이언트가 문제를 보거나 생각하지 않는다. 여기
public function postUpload()
{
$file = Input::file('file');
$name = time() . '-' . $file->getClientOriginalName();
$moved = $file->move(public_path() . '/uploads/CSV', $name);
DB::table('wc_program_1')->truncate();
$csv = new Reader($moved);
$csv->setOffset(0); //because we don't want to insert the header
$nbInsert = $csv->each(function ($row) use (&$sth) {
DB::table('wc_program_1')->insert(
array(
'Road' => $row[0],
'Parish' => $row[1],
'WorkType' => $row[2],
'TrafficManagement' => $row[3],
'Duration' => $row[4],
'Start' => $row[5]
)
);
return true;
});
return Redirect::to('admin/programmes')->with('flash_success', 'Upload completed & new data inserted.');
}
그리고 테이블 구조 :
이
이것은 'Parish'=> $ row [1], –
을 보여주는 행입니다. 내 대답을 읽었습니까? – MonkeyZeus
예 그들 각각을 위해, 나는 단지 당신의 질문에 대답하려고 노력할 것입니다. –