Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Client Script Forum > มีปัญหาเรื่องการอัพโหลดไฟล์ลง firebase storage ครับช่วยดูหน่อยครับ



 

มีปัญหาเรื่องการอัพโหลดไฟล์ลง firebase storage ครับช่วยดูหน่อยครับ

 



Topic : 136377



โพสกระทู้ ( 0 )
บทความ ( 0 )



สถานะออฟไลน์




หน้า console เว็บมันบอกว่า
Sign.php:217 Uncaught ReferenceError: firebase is not defined
at HTMLInputElement.<anonymous> (Sign.php:217)
แต่ผมงงว่ามัน error ยังไง

โค้ดที่มันบอกว่ามี error
var storageRef=firebase.storage().ref("Picture/"+file.name);


โค้ดเต็ม
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="Style form.css">
    <script src="https://kit.fontawesome.com/ac4dfd0a23.js" crossorigin="anonymous"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="icon" type="image/gif/png" href="images/logo.jpg">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
    <title>About Inkjet</title>
    <style>
        .image-preview{
            width: 50%;
            min-height: 100px;
            border: 2px solid #dddddd;
            margin-top : 15px;
            /*Default text*/
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: #cccccc;
            margin-left: 15%;
        }
        .image-preview__image{
            display:none;
            width: 100%;
        }
        #uploader{
            margin-left:15%;
        }
    </style>
</head>
<?php 
require_once('header.php'); 
?>
<body>
<!-- Page Wrapper -->
<div class="page-wrapper">

<!-- Form -->
<div class="container">
   <form action="process.php" method="POST"  enctype="multipart/form-data">
<center><h2>กรอกข้อมูลของท่าน</h2></center>
    <div>
    <div class="box"> 
   <label for="file">อัพโหลดรูป</label>
   <input type="file" accept=".jpg,.png,.jpeg" name="pic" id="inpFile" />
   <div class="image-preview" id="imagePreview">
        <img src="" alt="Image Preview" class="image-preview__image">
        <span class="image-preview__default-text">Image Preview</span>
    </div>
    <script>
        const inpFile = document.getElementById("inpFile");
        const previewContainer = document.getElementById("imagePreview");
        const previewImage = previewContainer .querySelector(".image-preview__image");
        const previewDefaultText = previewContainer .querySelector(".image-preview__default-text");
        
        inpFile.addEventListener("change", function(){
            const file = this.files[0];
            
            if (file) {
                const reader = new FileReader();

                previewDefaultText.style.display = "none";
                previewImage.style.display = "block";

                reader.addEventListener("load", function() {
                    console.log(this);
                    previewImage.setAttribute("src", this.result);
                });

                reader.readAsDataURL(file);
            }
        });
    </script>
    <progress value="0" max="100" id="uploader">0%</progress>


    <label for="size">ขนาดป้าย</label>
    <select name="select" id="size" required>
    <option  id="size" name="slct" value="" selected> เลือกขนาดป้ายไวนิล</option> 
    <option  id="size" name="slct1" value="1x1 เมตร,200" > 1x1 เมตร ราคา 200 บาท</option> 
    <option  id="size" name="slct2" value="1x2 เมตร,300" >1x2 เมตร ราคา 300 บาท</option> 
    <option  id="size" name="slct3" value="1x3 เมตร,450"> 1x3 เมตร ราคา 450 บาท</option>
    <option  id="size" name="slct4" value="1.20x2.40 เมตร,450" > 1.20x2.40 เมตร ราคา 450 บาท</option>
    <option  id="size" name="slct5" value="1.50x3 เมตร,750" > 1.50x3 เมตร ราคา 750 บาท</option>
    <option  id="size" name="slct6" value="2x4 เมตร,1,200"> 2x4 เมตร ราคา 1,200 บาท</option>
    </select><br>

    <label for="amou">จำนวน</label>
    <input type="text" id="amount" name="amount" onkeypress="return (event.charCode !=8 && event.charCode ==0 || ( event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57)))"placeholder="จำนวน" required><br>

    <label for="phnum">เบอร์ติดต่อ</label>
    <input type="tel" id="phnum" name="phone" onkeypress="return (event.charCode !=8 && event.charCode ==0 || ( event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57)))" placeholder="Your phone.." required><br>

    <label for="subject">รายละเอียด</label>
    <textarea id="subject" name="subject" placeholder="Write something.." style="height:100px" required></textarea>
    <br>

            <label for="name"><i class="fa fa-user"></i> ชื่อ-นามสกุล</label>
            <input type="text" id="name" name="name" placeholder="ชื่อ-นามสกุล" required>
            <label for="email"><i class="fa fa-envelope"></i> อีเมล</label>
            <input type="email" id="email" name="email" placeholder="[email protected]" required>
            <label for="adr"><i class="fa fa-address-card-o"></i> ที่อยู่</label>
            <input type="text" id="adr" name="address" placeholder="542 W. 15th Street" required>
            <label for="city"><i class="fa fa-institution"></i> จังหวัด</label>
            <input type="text" id="city" name="city" placeholder="Bangkok" required>
            <label for="zip"><i class="bi bi-mailbox"></i> รหัสไปรษณีย์</label>
            <input type="number" id="zip" name="zip"  onkeypress="return (event.charCode !=8 && event.charCode ==0 || ( event.charCode == 46 || (event.charCode >= 48 && event.charCode <= 57)))"" placeholder="10001" required>
    </div>
    <input type="submit" name="submit"  id="submit" value="ยืนยัน">
</form>
            </div>
          </div>
        </div>
    </div>
</div>
<!-- End PageWrapper -->
</body>
<script type="module">
  // Import the functions you need from the SDKs you need
  import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.1/firebase-app.js";
  import { getStorage } from "https://www.gstatic.com/firebasejs/9.0.1/firebase-storage.js";
  // TODO: Add SDKs for Firebase products that you want to use
  // https://firebase.google.com/docs/web/setup#available-libraries

  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  const firebaseConfig = {
    apiKey: "AIzaSyDAmerIVJpJVQMbpX1aTPHTkKuT1ULM_Gw",
    authDomain: "aboutinkjet-e6e0c.firebaseapp.com",
    projectId: "aboutinkjet-e6e0c",
    storageBucket: "aboutinkjet-e6e0c.appspot.com",
    messagingSenderId: "7922742945",
    appId: "1:7922742945:web:124d23113a55778727e2e0",
    measurementId: "G-4SETNPDNPB"
  };

  // Initialize Firebase
  const app = initializeApp(firebaseConfig);
  const storage = getStorage(app);

  var uploader=document.getElementById("submit");
  var fileButton = document.getElementById("inpFile");
  fileButton.addEventListener('change',function(e){
      var file=e.target.files[0];
      var storageRef=firebase.storage().ref("Picture/"+file.name);
      var task=storageRef.put(file);
      task.on('state_changed',function progress(snapshot){
        var percentage=(snapshot.bytesTransferred/snapshot.totalBytes)*100;
        uploader.value=percentage;
      },function error(err){
          console.log(err.message);
     },function complete(){
         console.log("Upload Complete!!!");
     });   
  });
</script>
<?php 
require_once('Footer.php'); 
?>
</html>




Tag : HTML, JavaScript, Cloud Database







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2021-09-06 11:02:07 By : Arno View : 583 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : มีปัญหาเรื่องการอัพโหลดไฟล์ลง firebase storage ครับช่วยดูหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่