please I want to store a file in s3 according to its directory, but when I do this code it saves the string “storage / ;;;” on a file but not the docx with its content??
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx"; Storage::disk('s3')->put("fusiondoc/doc",$path,'public');
I also tested with this code by adding Storage :: get but it does not work ?? Thank uu
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx"; $content = Storage::get($path); $full_path = Storage::disk('s3')->put("fusiondoc/doc",$content,'public');
Advertisement
Answer
Second parameter is content not path, so update like this
$path = "storage/uploads/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx"; Storage::disk('s3')->put("fusiondoc/doc/l42fZsuxHTWJhCCh1G9QZVqFVyyjPk8E0046sjAQ.docx",fopen($path),'public');
Update for comment
$fileName = uniqid () . Str::afterLast($path,"."); Storage::disk('s3')->put("fusiondoc/doc/" . $fileName,fopen($path),'public');