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; } 

image directory and writing to the database

  • As a solution to the problem - rename everything to lower case (or upper) and do the same thing with the database - Vladimir Klykov
  • Most likely you will have to do + tinker with the same names that will appear. I don’t understand why the register has changed, and not everywhere, but selectively - Denis Silantyev
  • It most likely did not change but became as specified in the database in scripts, just in win systems, case-insensitive paths, unlike nix, are Vladimir Klykov

0