aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/UploadForm.jsx
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-08-01 17:49:26 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2024-08-01 17:49:26 +0530
commitbd933a5aace3ac4944bfe7f4b58b4908978b4950 (patch)
treeb738f4c68d897c009ba7823d0e99f1f6b44a611d /src/components/UploadForm.jsx
parentfb04271b5288e8fb5891b7d6326f4806d12b82d5 (diff)
downloadadmin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.tar.gz
admin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.tar.bz2
admin-panel-bd933a5aace3ac4944bfe7f4b58b4908978b4950.zip
merge
Diffstat (limited to 'src/components/UploadForm.jsx')
-rw-r--r--src/components/UploadForm.jsx42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/components/UploadForm.jsx b/src/components/UploadForm.jsx
deleted file mode 100644
index 531feda..0000000
--- a/src/components/UploadForm.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import React, { useState } from 'react';
-import { ref, uploadBytesResumable, getDownloadURL } from 'firebase/storage';
-import { storage } from '../firebase';
-
-const UploadForm = ({ onUploadComplete }) => {
- const [file, setFile] = useState(null);
-
- const handleFileChange = (e) => {
- setFile(e.target.files[0]);
- };
-
- const handleUpload = () => {
- if (!file) return;
-
- const storageRef = ref(storage, `ads/${file.name}`);
- const uploadTask = uploadBytesResumable(storageRef, file);
-
- uploadTask.on('state_changed',
- (snapshot) => {
- // Observe state change events such as progress, pause, and resume
- },
- (error) => {
- console.error('Upload error:', error);
- },
- () => {
- // Handle successful uploads on complete
- getDownloadURL(uploadTask.snapshot.ref).then((downloadURL) => {
- onUploadComplete(downloadURL);
- });
- }
- );
- };
-
- return (
- <div>
- <input type="file" onChange={handleFileChange} />
- <button onClick={handleUpload}>Upload</button>
- </div>
- );
-};
-
-export default UploadForm;