I try move file from catalog 'storage/cvs/'
to 'storage/r_cvs/'
. I have code:
$getOldCV = $worker->cv;
$createCatalogNameCV = $request->name."_".$request->surname;
$createCatalogCV = iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $createCatalogNameCV);
// Storage::move('storage/cvs/'.$getOldCV, 'storage/r_cvs/' . $createCatalogCV . '/' . $getOldCV);
rename('storage/cvs/'.$getOldCV, 'storage/r_cvs/' . $createCatalogCV . '/' . $getOldCV);
When, I move file $getOldCV
, file are moved, but script remove all catalog 'storage/cvs/'
with files. I try use rename()
and Laravel function Storage::move
, but the effect is the same.
You might do a copy() and unklink() instead:
copy('storage/cvs/'.$getOldCV, 'storage/r_cvs/' . $createCatalogCV . '/' . $getOldCV);
unlink('storage/cvs/'.$getOldCV);
I change rename()
to move_uploaded_file()
, now script work correct
Since you're using Laravel, you can use the Storage::move()
method:
Storage::move(storage_path('csv/' . $getOldCV), storage_path('r_cvs/' . $createCatalogCV . '/' . $getOldCV));
Or File::move()
. It is different from the Storage::move()
:
File::move(storage_path('csv/' . $getOldCV), storage_path('r_cvs/' . $createCatalogCV . '/' . $getOldCV));
Also, make sure file permissions are correct for the storage
directory.