mardi 5 septembre 2017

Laravel 5.0: Change the name of an uploaded file

I have a file which I'm uploading, but the name doesn't appear to change. I would like to rename the file which I upload.

if ($request->hasFile('cv')){
    $file=$request->file('cv');
    $fileName= $user->lastName + date("Y-m-d H:i:s");
    $destinationPath=config('app.CVDestinationPath')."/cv";
    $uploaded = Storage::put($destinationPath, file_get_contents($file->getRealPath()));
}

This piece of code works properly in uploading, but it does not rename the file. How would I make the name of it to $fileName?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire