<?php
namespace App\Http\Livewire;
use Illuminate\Support\Facades\Http;
use Livewire\Component;
use Livewire\WithFileUploads;
class RequestService extends Component
{
use WithFileUploads;
public $attach;
private $serviceUrl = "http://multistep-form-livewire.test/api/";
public function upload()
{
$this->validate([
'attach' => 'max:2000'
]);
// here i put static tmp name but how to get it dynamically
$name = File::get(storage_path('app/livewire-tmp/XHsQgMvQEcGz17BOOad1TrTjGhLhJ0-metaU2NyZWVuc2hvdCAyMDIwLTEyLTAyIDE4Mjg1OS5qcGc=-.jpg'));
$url = $this->serviceUrl . "upload-external-file";
$response = Http::attach('attachment', $name, "testname")
->post($url, [
'name' => 'Sara',
'role' => 'Privacy Consultant',
]);
dd($response->status());
}
public function render()
{
return view('livewire.request-service');
}
}
what I want is to get the actual file from livewire temporary directory and send it to the API endpoint.