Hi I am trying to save file inside public folder using this file_put_contents() but in local it working fine it save file in public folder but in live server it save outside the public folder.
file_put_contents($lesson->id.'test'.$i.'.mp3', $resp->getAudioContent());
my local URL contains public word but live URL is without public word Thanks for any help
CodePudding user response:
You did not declare the root folder of your application the same as the server. To put your file in the public folder on the server do
file_put_contents('public/'.$lesson->id.'test'.$i.'.mp3', $resp->getAudioContent());
You can also use the absolute path of your public folder to make it work on both your local installation and the server
file_put_contents(public_path($lesson->id.'test'.$i.'.mp3'), $resp->getAudioContent());