Randy_Johnson's avatar

Livewire Image Upload Filename

I am trying to get the filename string. But I have no idea how to. I tried $this->photo->filename. I tried this e.g. $this->file->getClientOriginalName() of course but it just returns the original filename before the name is converted to a random string. The random string I don't mind for now, and I am in a big rush to get everything ready for the new year beginning in two months so its no fuss on my side.

Please help.

Livewire\TemporaryUploadedFile {#396 ▼
  +"disk": "local"
  #storage: Illuminate\Filesystem\FilesystemAdapter {#400 ▶}
  #path: "livewire-tmp/2k7fQRHRsxF6QAbVSjZcWoPUAjCRwi-metaMTgyNzQ3OTlfMTQ5MzUzNTc3NDA0MzYwM183OTIwNTAyOTA5NzI0MTQ5MTc2X24uanBn-.jpg"
  -test: false
  -originalName: "2k7fQRHRsxF6QAbVSjZcWoPUAjCRwi-metaMTgyNzQ3OTlfMTQ5MzUzNTc3NDA0MzYwM183OTIwNTAyOTA5NzI0MTQ5MTc2X24uanBn-.jpg"
  -mimeType: "application/octet-stream"
  -error: 0
  #hashName: null
  path: "C:\Users\Josh\AppData\Local\Temp"
  filename: "2k7fQRHRsxF6QAbVSjZcWoPUAjCRwi-metaMTgyNzQ3OTlfMTQ5MzUzNTc3NDA0MzYwM183OTIwNTAyOTA5NzI0MTQ5MTc2X24uanBn-.jpg"
  basename: "php1415.tmp"
  pathname: "C:\Users\Josh\AppData\Local\Temp\php1415.tmp"
  extension: "tmp"
  realPath: "D:\Josh\Computing\Projects\School_Tools\Register\storage\app\livewire-tmp/2k7fQRHRsxF6QAbVSjZcWoPUAjCRwi-metaMTgyNzQ3OTlfMTQ5MzUzNTc3NDA0MzYwM183OTIwNTAyOTA5NzI ▶"
  aTime: 2021-06-11 21:39:26
  mTime: 2021-06-11 21:39:26
  cTime: 2021-06-11 21:39:26
  inode: 19984723346561172
  size: 64687
  writable: false
  readable: false
  executable: false
  file: false
  dir: false
  link: false
}

0 likes
3 replies
Randy_Johnson's avatar

I found this but if anyone knows a better way am all ears.

            $url = Storage::url($this->photo->store('photos'));
Snapey's avatar
Snapey
Best Answer
Level 122
$filename = $this->photo->store('photos');
1 like
SHMDesign's avatar
$filename = $this->photo->getFilename();
1 like

Please or to participate in this conversation.