how does uploadModelStock() get called?
Mar 11, 2022
13
Level 2
File upload showing null
I've tried to follow what the documentation contains however I'm still getting null on every type of file I tried to upload.
My Livewire file
<form wire:submit.prevent="uploadData" enctype="multipart/form-data">
<div class="modal-body">
<div class="row justify-content-center">
<!--begin::Form-->
<div class="col-8">
<div class="form-group">
<input type="file" wire:model="file" class="form-control">
</div>
</div>
<!--end::Form-->
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Upload</button>
</div>
</form>
Livewire Controller
use App\Models\User;
use Livewire\Component;
use Google\Cloud\Firestore\FirestoreClient;
use Livewire\WithFileUploads;
class Uploader extends Component
{
use WithFileUploads;
public $file;
// trimmed all other functions
public function uploadData()
{
dd($this->file);
}
Level 2
Tagging this one as partly solved. For some reason, Livewire temporarily uploads the file (as POST request, seen in my debugbar) into storage/app/livewire-tmp. I then use $file->getPath().'/'.$file->getFilename() so I can use fopen(). I am now able to access the file contents
1 like
Please or to participate in this conversation.