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

Carl-Tabuso's avatar

Livewire File Upload

Need help with livewire, am frustrated af. Whenever i would try to upload a file, i'll get an error Trying to access array offset on null and when i look at the body of the error window i see this.

{
    "_token": "HoNkivgDRTzYnjNKfVDp3hbtO1x29YduoRNhgbzB",
    "components": [
        {
            "snapshot": "{"data":{"issue":[{"type":[[],{"s":"arr"}],"attachments":[[],{"s":"arr"}],"occuredAt":null,"confidentiality":null,"description":null,"desiredResolution":null},{"s":"arr"}]},"memo":{"id":"xr5k4jMD6WwsQfooFBq4","name":"employee.issues.create-issue","path":"employee/relations/issues/create","method":"GET","children":[],"scripts":["103409577-0"],"assets":[],"errors":[],"locale":"en"},"checksum":"9292ffaf024f10a813f6521eb8dd63d1e57f823c4b78c37994dc2c10832af38b"}",
            "updates": [],
            "calls": [
                {
                    "path": "",
                    "method": "_uploadErrored",
                    "params": [
                        "issue.attachments",
                        "
nWarning:  File upload error - unable to create a temporary file in Unknown on line 0
n{"message":"The files.0 failed to upload.","errors":{"files.0":["The files.0 failed to upload."]}}",
                        true
                    ]
                }
            ]
        }
    ]
}

i suspect that for some reason the file is just being lost when uploading and so when livewire tries to upload to temporary directory livewire-tmp i get this trying to access array on null. When i check the permissions for the folder, it seems that i have full control. What could be wrong here? This is the code.

<input type="file" wire:model="issue.attachments" multiple>
class className extends Component
{
    use WithFileUploads;

    public $issue = [
        // other props
        'attachments' => [],
    ];
0 likes
4 replies
Carl-Tabuso's avatar

@jlrdw appreciate it, but it didn't help me in any way. The episode didn't run into the issue i had. Further, everything done in the video, i had done beforehand. I still don't know the problem with the WithFileUploads trait. If i'm using the Storage facade i don't encounter any of this weird shits.

Snapey's avatar

You have access, how about your web server user?

Carl-Tabuso's avatar

Figured it out, it was dumb. Simply forgot to add myself in the permission of default tmp directory's account list.

Please or to participate in this conversation.