You cannot use domain in a file path. It has to be a proper path within the file system. You need to think about the file structure of your server and build the path accordingly.
Jul 28, 2017
5
Level 2
Creating Folder from a subdomain in Laravel into main domain in Laravel
I have 2 laravel files on my website, one is on a subdomain {sub.domain.com} and the other on the main domain {domain.com}.
I want to upload an image into the main public_html folder from the subdomain using Image intervention
The code below creates dynamic folder if it's not existing..
$path = "uploads/listings/house/" . $slug;
if(!File::exists("http://domain.com/".$path)){
File::makeDirectory("http://domain.com/". $path, 0777, true);
\Log::info('Driectory ' .$path. ' was created');
}else{
\Log::info('Driectory ' .$path. ' was NOT created');
}
This code get the Image, add a watermark and save to the location created above
$fileName = md5(time() .$image->getClientOriginalName()) ."." . strtolower($image->getClientOriginalExtension());
$img = Image::make($image->getRealPath());
// Main Photo
$img->fit(1080, 620)->insert(public_path('img/logo.png'), 'center')->save($path . '/' . $fileName);
The Issue
Trying to Upload, I receive a log message that the folder has been createdAfter having this, I get this error
Intervention\Image\Exception\NotReadableException: Image source not readable in /home2/username/laravel/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php:339
How can I achieve this
Please or to participate in this conversation.