You have the encrypt set in your form?
Jan 17, 2016
7
Level 13
file upload not working
I'm working on a support ticket system. User should be able to upload a file to each ticket reply.
My view:
@if($errors->has()) @foreach ($errors->all() as $error) {{ $error }} @endforeach @endif
my controller:
public function postTicket(Request $request)
{
$validator = Validator::make($request->all(), [
'departments' => 'required|exists:departments,id',
'attachment' =>'max:1000',
]);
if ($validator->fails())
return back()->withErrors($validator)->withInput();
if ($request->hasFile('attachment'))
{
if ($request->file('attachment')->isValid())
{
$file = Request::file('attachment');
$extension = $file->getClientOriginalExtension();
Storage::disk('local')->put($file->getFilename().'.'.$extension, File::get($file));
$entry = new Fileentry();
$entry->mime = $file->getClientMimeType();
$entry->filename = $file->getFilename().'.'.$extension;
$entry->save();
dd("uploaded");
}
dd("upload failed");
}
dd("no file");
}
New files should be saved "protected" into the storage system. All the time I check my code it says "no file". Any idea I make a mistake?
Please or to participate in this conversation.