The file name Laravel

Asked

Viewed 418 times

1

I’m saving a file on Amazon’s AWS S3, the file is being saved but it puts an underline and a number in front, as shown below:

inserir a descrição da imagem aqui

And this is in the way of getting the URL of the PDF to show the PDF to the user, you could take this number, or a function that takes the URL of the object?

I tried this but it doesn’t bring the Object URL:

$Url=Storage::disk('s3')->url($filename);

Code that is saving the file on the server:

 $filenamewithextension = $request->file('doc')->getClientOriginalName();

        $dia=date('d/m/Y');
        $horario=date("H.i.s");
        $id=Auth::user()->id;
        $filename ='teste';


        $extension = $request->file('doc')->getClientOriginalExtension();


        $filenametostore = $filename.'_'.time().'.'.$extension;


        Storage::disk('s3')->put($filenametostore, fopen($request->file('doc'), 'r+'), 'public');

1 answer

1


on the line

$filenametostore = $filename.'_'.time().'.'.$extension;

is where the number is inserted, remove the '_'.time().'.' and this number will not appear (it should look like this: $filename.$extension) but be careful, someone created this code this way because there may be name conflicts.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.