import { useState } from "react";
Thursday, 13 March 2025
OPT section in web site
Wednesday, 12 March 2025
How to take image form the file and save in local storage and get form there ...
<h1> Input and Save Image </h1>
import React, { useEffect, useState } from 'react';
function Auth() {
const [file, setFile] = useState(null);
useEffect(() => {
// Load the image from localStorage on page load
const storedFile = localStorage.getItem('file');
if (storedFile) {
setFile(storedFile);
}
}, []);
function handleChange(e) {
const selectedFile = e.target.files[0];
if (selectedFile) {
const reader = new FileReader();
reader.onloadend = () => {
// Convert image to base64 and store in localStorage
localStorage.setItem('file', reader.result);
setFile(reader.result);
};
reader.readAsDataURL(selectedFile);
}
}
return (
<div className="App">
<h2>Add Image:</h2>
<input type="file" onChange={handleChange} />
{file && <img src={file} alt="Preview" style={{ width: '200px', marginTop: '10px' }} />}
</div>
);
}
export default Auth;
Friday, 14 February 2025
Email From by Node and express
2️⃣ Advanced: Node.js + Express Backend
If you want to store form data in MongoDB or send emails using Nodemailer,create a backend.1️⃣ Simple Method: Formspree (No Backend)
1️⃣ Simple Method: Formspree (No Backend)
import React, { useState } from "react";
function Contact() {
const [status, setStatus] = useState("");
const handleSubmit = async (event) => {
event.preventDefault();
const formData = new FormData(event.target);
const response = await fetch("https://formspree.io/f/YOUR_FORM_ID", {
method: "POST",
body: formData,
headers: { Accept: "application/json" },
});
if (response.ok) {
setStatus("Thanks for your message!");
event.target.reset(); // Clear form after successful submission
} else {
setStatus("Oops! Something went wrong.");
}
};
return (
{/* Contact Info */}
Contact
Looking forward to hearing from you
- Phone
- 98575545525
- Email
- info@gmail.com
{/* Contact Form */}
);
}
export default Contact;
3D card hover
import { motion } from "framer-motion"; import React from "react"; const Card = ({ title, price, image }) => { ret...
-
<h1> Input and Save Image </h1> import React, { useEffect, useState } from 'react'; function Auth() { const [file, set...
-
1️⃣ Simple Method: Formspree (No Backend) import React, { useState } from "react"; function Co...
