/home/u764571690/domains/savitrfoundation.com/public_html
NameSizeModeActions
admin/-0755rm
ajax/-0755rm
api/-0755rm
assets/-0755rm
cache/-0755rm
certificate_view/-0755rm
css/-0755rm
documents_upload/-0755rm
F2/-0755rm
finger data/-0755rm
functions/-0755rm
hts-cache/-0755rm
js/-0755rm
logs/-0755rm
pages/-0755rm
privacy policy/-0755rm
savitrfoundation/-0755rm
scholar/-0755rm
terms and conditions/-0755rm
tmp/-0755rm
uploads/-0755rm
.htaccess35830644editdlrm
.htaccess.htaccess92230644editdlrm
.user.ini6230644editdlrm
ads.txt580644editdlrm
application.php416470644editdlrm
backblue.gif42430644editdlrm
careers.php184020644editdlrm
fade.gif8280644editdlrm
how to apply.php448520644editdlrm
hts-log.txt27380644editdlrm
index.php500644editdlrm
ngo_account_open.php279840644editdlrm
our_scholars.php118820644editdlrm
php.ini6170644editdlrm
reupload_document.php60380644editdlrm
robots.txt2910644editdlrm
scholarshipapply.php2197690644editdlrm
scholarshipportal.php899930644editdlrm
sendmail.php27200644editdlrm
sitemap.xml37430644editdlrm
submit-internship-application.php88560644editdlrm
sw.js1560644editdlrm
upload_document_main.php61210644editdlrm
Edit: /home/u764571690/domains/savitrfoundation.com/public_html/reupload_document.php (6038B)
prepare("SELECT * FROM documents WHERE id = ? AND applicant_id = ?"); $stmt->execute([$documentId, $applicantId]); $oldDocument = $stmt->fetch(PDO::FETCH_ASSOC); if (!$oldDocument) { throw new Exception('Document not found'); } // Verify the document type matches if ($oldDocument['document_type'] !== $documentType) { throw new Exception('Document type mismatch'); } // Get applicant details to get the folder path $stmt = $pdo->prepare("SELECT application_id FROM applicants WHERE applicant_id = ?"); $stmt->execute([$applicantId]); $applicant = $stmt->fetch(PDO::FETCH_ASSOC); if (!$applicant) { throw new Exception('Applicant not found'); } // Use the same directory as the old document $oldPath = $oldDocument['document_path']; $directory = dirname($oldPath); // Ensure directory exists if (!file_exists($directory)) { mkdir($directory, 0777, true); } // Generate new filename with WebP extension $fileName = $documentType . '_' . time() . '.webp'; $filePath = $directory . DIRECTORY_SEPARATOR . $fileName; // Convert to WebP format $webpPath = convertToWebP($file['tmp_name'], $filePath, 80); if (!$webpPath) { throw new Exception('Failed to convert image to WebP format'); } // Get WebP file size for response $webpSize = filesize($webpPath); $originalSize = $file['size']; // Begin transaction $pdo->beginTransaction(); try { // Delete old document file if it exists if (file_exists($oldPath)) { unlink($oldPath); } // Update document record in database $stmt = $pdo->prepare(" UPDATE documents SET document_name = ?, document_path = ?, status = 'pending', uploaded_at = NOW() WHERE id = ? AND applicant_id = ? "); $stmt->execute([ $file['name'], $webpPath, $documentId, $applicantId ]); // Commit transaction $pdo->commit(); // Return success response with compression details echo json_encode([ 'success' => true, 'message' => 'Document re-uploaded and converted to WebP successfully. It will be reviewed shortly.', 'document_id' => $documentId, 'file_name' => $file['name'], 'original_size' => round($originalSize / 1024, 2), 'webp_size' => round($webpSize / 1024, 2), 'saved_percentage' => round((($originalSize - $webpSize) / $originalSize) * 100, 2) ]); } catch (Exception $e) { // Rollback transaction $pdo->rollBack(); throw $e; } } catch (Exception $e) { // Return error response echo json_encode([ 'success' => false, 'message' => $e->getMessage() ]); } ?>