Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bogdy's avatar
Level 10

Issue with Uploading .bin Files in Laravel

I'm currently working on a project in Laravel where I need to upload .bin firmware files. I'm facing an issue where Laravel does not seem to recognize the .bin file type correctly. Upon using dd($this->file), I noticed that the hashName property is null. This seems unusual and might be part of the issue.

What I Need Help With: I'm looking for suggestions or guidance on how to properly handle .bin file uploads in Laravel. Specifically, I need to ensure that the file is correctly identified as a .bin file and stored in the desired directory with the correct name and extension.

Any advice or insights from those who have encountered and resolved similar issues would be greatly appreciated. Thank you in advance for your help!

0 likes
6 replies
martinbean's avatar

@bogdy A .bin file is just a binary file. It has no “type”. There’s nothing to “identify” because a binary file (1s and 0s) could be literally anything.

bogdy's avatar
Level 10

@martinbean ok. i understand, but i can't upload the file even if i take out the verfication

martinbean's avatar

@bogdy Why can’t you upload the file?

  • What are you trying?
  • What result are you getting?
  • What result do you get instead?

We’re not clairvoyant. We can’t see your screen. We don’t know what you’re doing or what’s happening. Saying “it doesn’t work” or “I can’t do X” doesn’t help any one to help you.

bogdy's avatar
Level 10

@Snapey

<?php

namespace App\Livewire\Firmware;

use App\Models\CoffeeMachine;
use App\Models\FirmwareUpdate;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Application;
use Livewire\Component;
use Livewire\WithFileUploads;

class FirmwareCreate extends Component
{
    use WithFileUploads;
    public $version;
    public $file;
    public $description;
    public $code;
    public $coffee_machine_id;

    public $machine_type;

    protected function rules(): array
    {
        return [
            'version' => 'required|string|max:255',
            'file' => 'nullable',
            'description' => 'nullable|string|max:1024',
            'machine_type' => 'nullable|string|max:255',
            'code' => 'nullable',
            'coffee_machine_id' => 'required|exists:coffee_machines,id',
        ];
    }

    public function getCoffeeMachinesProperty(): Collection
    {
        return CoffeeMachine::all();
    }

    public function submit()
    {
        //TODO upload bin
        //dd($this->file, $this->file->getClientOriginalName(), $this->file->getRealPath());
        //dd($this->file);
        //dd($this->file->getClientOriginalExtension());
        //dd($this->file->getMimeType());
        $this->validate();

  
        $filePath = $this->file->store('firmware');

        FirmwareUpdate::create([
            'version' => $this->version,
            'file_path' => $filePath,
            'code' => $this->code,
            'description' => $this->description,
            'machine_type' => $this->machine_type,
            'coffee_machine_id' => $this->coffee_machine_id,
        ]);

        session()->flash('message', 'Uhuu Firmware.');

        return redirect()->to('/firmware');
    }
    public function render(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
    {
        return view('livewire.firmware.firmware-create', [
            'coffeeMachines' => $this->coffeeMachines
        ]);
    }
}

Snapey's avatar

@bogdy Ah, so we find its livewire! What version?

What have you setup for firmware disk?

Please or to participate in this conversation.