Closed WBDC closed 4 years ago
Could be your storage setup. Right now it defaults to public
. Check the network
tab of chrome after you select a file - getting any errors from the response?
Could be your storage setup. Right now it defaults to
public
. Check thenetwork
tab of chrome after you select a file - getting any errors from the response?
When I upload the file in the normal Controller it uploads the file just fine. Of course, for that, I use csrf token and post method. It uploads the file and puts it into the storage.
The $this->form_data
shows that the img array is empty.
When I remove the dd($this->form_data)
it throws an error
<!doctype html>
<html class="theme-light">
<!--
Symfony\Component\Routing\Exception\RouteNotFoundException: Route [imgs.create] not defined. in file C:\wamp64\www\wbdsupport\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php on line 420
#0 C:\wamp64\www\wbdsupport\vendor\laravel\framework\src\Illuminate\Routing\Redirector.php(176): Illuminate\Routing\UrlGenerator->route('imgs.create', Array)
#1 C:\wamp64\www\wbdsupport\app\Http\Livewire\ImgForm.php(27): Illuminate\Routing\Redirector->route('imgs.create')
#2 C:\wamp64\www\wbdsupport\vendor\kdion4891\laravel-livewire-forms\src\FormComponent.php(93): App\Http\Livewire\ImgForm->saveAndStayResponse()
#3 C:\wamp64\www\wbdsupport\vendor\livewire\livewire\src\ComponentConcerns\HandlesActions.php(88): Kdion4891\LaravelLivewireForms\FormComponent->saveAndStay()
#4 C:\wamp64\www\wbdsupport\vendor\livewire\livewire\src\Connection\ConnectionHandler.php(51): Livewire\Component->callMethod('saveAndStay', Array)
#5 C:\wamp64\www\wbdsupport\vendor\livewire\livewire\src\Connection\ConnectionHandler.php(21): Livewire\Connection\ConnectionHandler->processMessage('callMethod', Array, Object(App\Http\Livewire\ImgForm))
#6 C:\wamp64\www\wbdsupport\vendor\livewire\livewire\src\Connection\HttpConnectionHandler.php(11): Livewire\Connection\ConnectionHandler->handle(Array)
#7 C:\wamp64\www\wbdsupport\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(48): Livewire\Connection\HttpConnectionHandler->__invoke('img-form')
Is this any help for you?
Let me know what other information you need.
It's because the imgs.create
route that you're using in the saveAndStay()
method doesn't exist.
Hi Kevin,
I tried to check where it goes wrong without any success.
The route naming was my fault. Added it now, although seems like it doesn't like POST route, and it accepts a GET route. Here is all my stuff so hopefully you can see what's the problem.
Migration
Model
Route
Component
Again, I would expect some data to be shown when hits the imgs.create
route, but the request()->all()
returns an empty array.
Is there anything in your laravel error log? Once a file is picked the component uploads it via axios through the package "upload-file" route, which actually just calls the component uploadFile
function via AJAX.
Closing for now until I hear a response.
Make sure you added @stack('scripts')
to your layout file where javascript goes.
I have this same issue, please advice
I am also having this same issue
Hi,
First, let me say thank you for this awesome package!
I was trying to help for a Livewire fellow (link) about file upload. initially I thought I still an manage this process by using the Image intervention package, but its not that simple.. I had a quick read on the Livewire articles and I came across your package.
I've followed your documentation, but seems like this doesn't work (at least for me) for file uploads.
I've casted the image as an array.
Could you please advise?
Many thanks!