$file !== '.' && $file !== '..' && is_file($path . $file) && pathinfo($file, PATHINFO_EXTENSION) === 'txt' ); $data = []; foreach ($files as $file) { $data[] = [ 'filename' => $file, 'content' => file_get_contents($path . $file), // plain text content ]; // Optional: move processed file to Out rename($path . $file, '/srv/pds.iotsignin.com/sapftp/Out/' . $file); } return response()->json([ 'status' => 'success', 'files' => $data, ]); } /** * Display the specified resource. */ public function show(string $id) { // } /** * Update the specified resource in storage. */ public function update(Request $request, string $id) { // } /** * Remove the specified resource from storage. */ public function destroy(string $id) { // } }