❌ No file uploaded.
"); } $file = $_FILES["file"]; $fileName = $file["name"]; $fileTmpName = $file["tmp_name"]; $fileSize = $file["size"]; $fileType = mime_content_type($fileTmpName); $uploadDir = "tender_docs/"; // Create upload directory if not exists if (!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } // Validate file type if ($fileType !== "application/pdf") { die("❌ Invalid file type. Only PDFs are allowed.
"); } // Validate file size (5MB max) if ($fileSize > 5 * 1024 * 1024) { die("❌ File is too large. Max 5MB allowed.
"); } // Generate unique file name $newFileName = uniqid() . "_" . basename($fileName); $targetPath = $uploadDir . $newFileName; // Move the uploaded file if (move_uploaded_file($fileTmpName, $targetPath)) { echo "✅ File uploaded successfully: $newFileName
"; } else { echo "❌ Error uploading file.
"; } } ?>