I uploaded images from a third-party server, while creating a directory, if it does not exist, the picture itself was saved in it, the corresponding location record was inserted into the database. Everything worked fine (whatever register in the openserver url on windows finds an image) and only when transferring the site to ubuntu apache I found out that the register of some records and folders is different, as a result, images are not loaded. With that only nekotryh without patterns. What could be the reason and how to fix it (re-uploading images is not an option - all were sub-photoshoped)?
// сохранение картинок public function store(Request $request) { $path = public_path().'\images\\'; //$file = $request->file('file'); $images = car_image::where('path', ''); foreach ($images as $image) { $ch = curl_init($image->cc_url); $filename = str_random(2).'\\'.str_random(2).'\\'.str_random(4) .'.jpg'; // создаем каталог если он не создан $dirname = dirname($path.$filename); if (!is_dir($dirname)) { mkdir($dirname, 0755, true); } // загружаем и сохраняем файл $fp = fopen($path.$filename, 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $image->path = $filename; $image->save(); } return 1; } 