Excel faylni tanlang

Natija (JSON)


// A JavaScript example for an API
    
  const form = document.getElementById('excelForm');
    const resultArea = document.getElementById('resultArea');

    form.addEventListener('submit', function(e) {
      e.preventDefault();

      const fileInput = document.getElementById('fileInput');
      const file = fileInput.files[0];

      if (!file) {
        alert("Iltimos, Excel fayl tanlang.");
        return;
      }

      const formData = new FormData();
      formData.append("file", file);

      resultArea.value = "⏳ Yuklanmoqda...";

      fetch("https://alfraganus.uz/excel/excel-to-json.php", {
        method: "POST",
        body: formData
      })
      .then(response => response.json())
      .then(data => {
        resultArea.value = JSON.stringify(data, null, 2);
      })
      .catch(error => {
        resultArea.value = "❌ Xatolik yuz berdi: " + error;
      });
    });