Feat: Save files in storae with original name and user name
This commit is contained in:
@@ -36,7 +36,10 @@ class FacultyController extends Controller
|
||||
// Handle the file upload
|
||||
$proofPath = null;
|
||||
if ($request->hasFile('proof')) {
|
||||
$proofPath = $request->file('proof')->store('proofs', 'public');
|
||||
$originalName = $request->file('proof')->getClientOriginalName();
|
||||
$username = auth()->user()->name;
|
||||
$fileName = $username . '_' . $originalName;
|
||||
$proofPath = $request->file('proof')->storeAs('proofs', $fileName, 'public');
|
||||
}
|
||||
|
||||
// Save the response to the database
|
||||
@@ -51,8 +54,8 @@ class FacultyController extends Controller
|
||||
|
||||
return redirect()->route('faculty.dashboard')->with('status', 'Response submitted successfully');
|
||||
} catch (\Exception $e) {
|
||||
// Dump the error and stop execution for debugging
|
||||
dd($e->getMessage());
|
||||
// Handle the exception and provide an error message
|
||||
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user