0

I am developing a system in which can upload a CSV file and view it in an HTML table. After uploading CSV file saves in the database with an id, but I can't read that CSV file and view it in the HTML table. I want to read the CSV file into an array and then view it in the table. Please help me. It will be a great deal.

Controller files:- projectController

<?PHP
class ProjectController extends Controller
{
 public function index($id)
{
    $project = Project::find($id);
    $data = array();
    // read the CSV and assign the data to $data
    return view('home')->with('project', $project)->with('data', $data);
   }
  }

uploadFileController

public function index()
 {
  return view('/');
 }
public function upload(Request $request)
 {
  $file = $request->file('csv');

  $project = new Project();

  $project->name = $request->name;

  $project->save();

  print_r($file);

  //Move Uploaded File
  $destinationPath = 'uploads';
  $file->move($destinationPath, $project->id . '.' . $file->getClientOriginalExtension());

  return redirect("/project/{$project->id}");
}

This is how it looks:https://i.sstatic.net/yosHN.jpg

4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.