I have a server using CentOS 7 as our virtual server. Upon testing, I'm receiving an error :
Can't write image data to path (/var/www/html/project/storage/app/public/tmp/5b805117b888e261406aab6201c9a812581550ca.png)
Upon checking the permission, I have the read and write permissions already. Command ls -la public/storage/tmp/
. Result is :
total 8
drwxrwxrwx 2 apache apache 4096 Oct 22 23:47 .
drwxrwxrwx 3 apache apache 4096 Oct 22 23:47 ..
And in my php files, I have checked if the directory exist, else create if not.
service.php
$server_dir = 'storage/tmp';
FileHelper::addDirectory($server_dir, 0777);
$file_name = FileHelper::makeUniqFileName($photo->getClientOriginalExtension(), $server_dir);
$filepath = $server_dir;
$img_path = FileHelper::storeResizeImg($photo->path(), storage_path('app/public/') . "tmp/" . $file_name, null, 300);
$img_url = FileHelper::getPublicPath($img_path);
return $img_url;
helper.php
public static function addDirectory($directory, $mod)
{
if (!File::exists($directory)) {
File::makeDirectory($directory, $mod, true);
}
}
I also run php artisan storage:link
already.
This works in my local but not in my server. Can someone point out what I'm missing?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire