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

JonniFin's avatar

Nova getClientOriginalName()

File::make('File')
                ->disk('downloads')
                ->storeAs(function (Request $request) {
                    Log::info($request);
                    Log::info($request->file);
                    return sha1($request->file->getClientOriginalName());
                }),

Will store the file, but not with the original name? What I am missing here?

[2022-12-20 15:38:04] local.INFO: array (
  'name' => 'H7s3keKQ58',
  '_method' => 'PUT',
  '_retrieved_at' => '1671550678',
  'viaResource' => NULL,
  'viaResourceId' => NULL,
  'viaRelationship' => NULL,
  'editing' => 'true',
  'editMode' => 'update',
  'file' => 
  Illuminate\Http\UploadedFile::__set_state(array(
     'test' => false,
     'originalName' => 'automation_1.jpg',
     'mimeType' => 'image/jpeg',
     'error' => 0,
     'hashName' => NULL,
  )),
)  
[2022-12-20 15:38:04] local.INFO: /tmp/phpIuksKG  

I would like the Nova to upload the file using the automation_1.jpg file name, not the random string.

0 likes
3 replies
kleninmaxim's avatar
Level 50

Have you tried removing the function sha1?

File::make('File')
                ->disk('downloads')
                ->storeAs(function (Request $request) {
                    Log::info($request);
                    Log::info($request->file);
                    return $request->file->getClientOriginalName();
                }),
JonniFin's avatar

@Klenin confirmed: this works.

And also, i did not think that part through. It was really a customized string, not using the original name passed...

File::make('File')
                ->disk('downloads')
                ->storeAs(function (Request $request) {
                    Log::info($request);
                    Log::info($request->file);
                    return $request->file->getClientOriginalName();
                }),
kleninmaxim's avatar

Or maybe you need to use as array: Log::info($request['file']); or try Log::info($request['file']->getClientOriginalName());

Please or to participate in this conversation.