Hi Guys,
I am trying to upload images to the storage folder that is located above the public_html folder on my server so that I am able to hide my .env file etc.
So what I am doing is creating the directory in the storage folder which is working fine:
if(!Storage::exists("/public/images/$userName"))
{
Storage::makeDirectory("/public/images/$userName");
}
if(!Storage::exists("/public/images/$userName/$auditTitle"))
{
Storage::makeDirectory("/public/images/$userName/$auditTitle");
}
if(!Storage::exists("/public/images/$userName/$auditTitle/$date"))
{
Storage::makeDirectory("/public/images/$userName/$auditTitle/$date");
}
$fullPath = "/public/images/$userName/$auditTitle/$date";
return $fullPath;
Once this is done it is passed to the queue where it is processed and added to the file structure and uploaded to the DB:
public function handle()
{
if ($this->auditimage['Base64Image'])
{
Log::info('Adding New image ');
$mime = explode(';', $this->auditimage['Base64Image']);
$mime1 = explode(':', $mime[0]);
$type = explode('/', $mime1[1]);
$image = Image::make($this->auditimage['Base64Image'])->resize(1000, 1000, function ($constraint) {
$constraint->aspectRatio();});
Storage::putFileAs($fullPath, $image, $filename);
$image->destroy();
I have passed the fullpath and the filename from the controllers.
When I check the file structure it has created the directories with no issues but does not add the image to it and then in DB in the failed jobs table I get:
ErrorException: file_put_contents(/home/custzone/auditstagingcore/storage/app/public/images/Matthew_Morris/Title_Dan/2017-12-20): failed to open stream: Is a directory in /home/custzone/auditstagingcore/vendor/league/flysystem/src/Adapter/Local.php:198
Any help would be appreciated to get this to work.