function compress_png($path_to_png_file, $max_quality = 90) { if (!file_exists($path_to_png_file)) { throw new Exception("File does not exist: $path_to_png_file"); // ругается на эту строку } $min_quality = 60; $compressed_png_content = shell_exec("/home/tmp/pngquant 2>&1 --quality=$min_quality-$max_quality - < ".escapeshellarg($path_to_png_file)); if (!$compressed_png_content) { echo "0"; } return $compressed_png_content; } The code worked until yesterday, and suddenly it stopped working, the Apache rebooted, the server rebooted and nothing.
Fatal error: Uncaught exception 'Exception' with message 'File does not exist: ./pic/zombie-smashdown-dead-warrior481.png' in /home/admin/web/site.com/public_html/sql.php:10 Stack trace: #0 /home/admin/web/site.com/public_html/sql.php(122): compress_png('./pic/zombi...') #1 {main} thrown in /home/admin/web/site.com/public_html/sql.php on line 10 And this is the 122 line:
$path_to_uncompressed_file = './pic/'.p($_POST['title']).$rand_img.'.png'; $path_to_compressed_file = './pic/'.p($_POST['title']).'_'.$rand_img.'.png'; file_put_contents($path_to_compressed_file, compress_png($path_to_uncompressed_file)); // 122 stkora unlink($path_to_uncompressed_file);