Avoiding exceptions when uploading files in laravel
- by occam98
I've got a file upload field (attachment1) in a form that may or may not have a file uploaded in it when I process the form in laravel.
When I'm trying to process the page, this line generates an exception:
Input::upload('attachment1',path('storage').'attachments/'.$name);
Here is the text of the exception:
Message:
Call to a member function move() on a non-object
it seems that I need to check in advance to see if 'attachment1' has a file, and I found that the function Input::has_file('attachment1') is supposed to tell me whether or not 'attachment1' has a file, but even when I submit an empty form, it returns true.
Also, from reading documentation, it seems that Input::upload is supposed to just return false when trying to upload a non-existant file, so why does it produce this exception instead, and how can I fix it?