:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/kreativecrm/**
:: Editing File: save_invoice_image.php
<?php include 'config/db.php'; // DB connection include 'check_login.php'; if (!empty($_POST['image']) && !empty($_POST['invoice_no'])) { $img = $_POST['image']; $invoice_no = $_POST['invoice_no']; // Folder to save image $folder = "uploads/invoice_images/"; if (!file_exists($folder)) { mkdir($folder, 0777, true); } // Convert base64 → image $img = str_replace('data:image/jpeg;base64,', '', $img); $img = str_replace(' ', '+', $img); $fileName = $folder . $invoice_no . '.jpg'; file_put_contents($fileName, base64_decode($img)); // ✅ Crop image (remove left/right space) if (file_exists($fileName)) { $image = imagecreatefromjpeg($fileName); if ($image) { $width = imagesx($image); $height = imagesy($image); // Adjust these margins to your preference $leftCrop = 400; // pixels to remove from left $rightCrop = 400; // pixels to remove from right $topCrop = 0; $bottomCrop = 0; // Ensure values don’t exceed image size if (($leftCrop + $rightCrop) < $width) { $newWidth = $width - ($leftCrop + $rightCrop); $newHeight = $height - ($topCrop + $bottomCrop); $cropped = imagecrop($image, [ 'x' => $leftCrop, 'y' => $topCrop, 'width' => $newWidth, 'height' => $newHeight ]); if ($cropped !== FALSE) { // Overwrite same file with cropped version imagejpeg($cropped, $fileName, 100); imagedestroy($cropped); } } imagedestroy($image); } } // ✅ Update DB with cropped image path $query = "UPDATE invoices SET pdf_path = '$fileName' WHERE invoice_no = '$invoice_no'"; mysqli_query($conn, $query); echo "✅ Cropped & Saved: " . $fileName; } else { echo "❌ Missing data"; } ?>