Home>

Please describe your question here in detail.
I want to upload a 360 degree image (jpeg) with PHP (Laravel 7).

A normal image (jpeg) was easily realized,
An error occurs in the 360 ​​degree image (jpeg) taken with the RICOH THETA 360 degree camera.

The following error message occurred while uploading a 360-degree image (jpeg).

Symfony\Component\Mime\Exception\InvalidArgumentException
The "" file does not exist or is not readable.
Applicable source code

[View]

<form method="POST" action="{{route('image.store')}}" enctype="multipart/form-data">
    @csrf
  <input type="file" name="file">
  <input type="submit" value="upload">
</form>

[Controller]

public function store(Request $request)
{
   $path = $request->file->store('public/images');
}
What I tried

With the debug command on the controller side
I checked the contents of the normal image and the 360-degree image.
dd($request->file);

When comparing the results of both, the attributes such as mime were completely different.

[For normal image files]

[In the case of an error 360-degree image file]

Supplemental information (FW/tool ​​version, etc.)

PHP 7.3.11
Laravel Framework 7.14.1

Please teach me how to upload a 360-degree image.

You can upload it in another way, for example with an FTP tool, as usual
If i can upload via FTP with Laravel,
You can do it that way.
* I googled, but couldn't find it.

  • Answer # 1

    By checking the contents of the image,dd($request->file);Please take a closer look at the contents of the "360 degree image".

    Neither path nor filename are included, right?
    This, I can not upload the file to the server in the first place.

    Files that could not be uploaded do not have temporary files, so
    It cannot be moved. (Same for FTP and SFTP)

    The file size was too big and it was played,
    Isn't there a cause in such a basic place?


    Incidentally. ..

    If you talk about code,
    I am trying to operate the file with "I thought I could POST" without applying validation,
    Not very nice.

    At the least, it's better to check if the upload was successful.

    if($request->file->isValid()){
      $path = $request->file->store('public/images');
    }else{
      //If there is no file, try returning with an error message on the input screen
      return redirect()->back()->withErrors("File upload failed!");
    }

    By the way, it is a mime type that I was worried about comparing the contents of files,

    -mimeType: "application/octet-stream"

    Like this time, if the file is not uploaded, I think this will be displayed by default, so
    It is likely to be different from the actual 360 degree image mime type.

    And$request->file->store()Unless you've done some elaborate customization
    It should be a relatively simple process of moving the temporary file to the specified path, so I don't think that mime type etc. will basically affect this process.