|
@@ -212,6 +212,7 @@ class HomeController extends Controller
|
|
|
|
|
|
// Validate the URL
|
|
// Validate the URL
|
|
if (filter_var($imageUrl, FILTER_VALIDATE_URL) === false) {
|
|
if (filter_var($imageUrl, FILTER_VALIDATE_URL) === false) {
|
|
|
|
+ Session::put('downloadAllStatus', '2');
|
|
return response()->json(['error' => 'Invalid URL'], 400);
|
|
return response()->json(['error' => 'Invalid URL'], 400);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -229,6 +230,7 @@ class HomeController extends Controller
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
|
if ($httpCode !== 200) {
|
|
if ($httpCode !== 200) {
|
|
|
|
+ Session::put('downloadAllStatus', '2');
|
|
return response()->json(['error' => 'Failed to download image'], 500);
|
|
return response()->json(['error' => 'Failed to download image'], 500);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -237,13 +239,13 @@ class HomeController extends Controller
|
|
// Generate a random filename
|
|
// Generate a random filename
|
|
$fileName = Str::random(32) . '.jpg';
|
|
$fileName = Str::random(32) . '.jpg';
|
|
|
|
|
|
- Session::put('downloadAllStatus', '0');
|
|
|
|
|
|
+ Session::put('downloadAllStatus', '2');
|
|
// Return the image as a download
|
|
// Return the image as a download
|
|
return response($imageContent)
|
|
return response($imageContent)
|
|
->header('Content-Type', 'image/jpeg')
|
|
->header('Content-Type', 'image/jpeg')
|
|
->header('Content-Disposition', 'attachment; filename="' . $fileName . '"');
|
|
->header('Content-Disposition', 'attachment; filename="' . $fileName . '"');
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
- Session::put('downloadAllStatus', '0');
|
|
|
|
|
|
+ Session::put('downloadAllStatus', '2');
|
|
return response()->json(['error' => 'Error downloading image: ' . $e->getMessage()], 500);
|
|
return response()->json(['error' => 'Error downloading image: ' . $e->getMessage()], 500);
|
|
}
|
|
}
|
|
}
|
|
}
|