• Techblog369, India
  • September 29, 2022

How to create PHP QR code and Save it to Database?

Hi In this Article I am going to show how to create QR code and save it to database also fetch QR Code in a Table Create a Page addqrcode.php in …

How to Send Multiple Files Attachment Mail using Laravel

Hi in this article i am going to show how to send multiple files attachment mail in Laravel. It’s simple example of Laravel send multiple attachment in mail. I explained simply …


import { useState } from 'react'
import Swal from 'sweetalert2';
function Addservice() {
   const [ServiceName, setName] = useState("");
   const [ServiceDesc, setDesc] = useState("");
   const [file, setFile] = useState("");
   async function Addservice() {
       // const token = localStorage.getItem("token")
       //const token = JSON.parse(localStorage.getItem('token'));
       const user = JSON.parse(localStorage.getItem('token'));
       const formData = new FormData();
       formData.append('ServiceName', ServiceName);
       formData.append('ServiceDesc', ServiceDesc);
       formData.append('file', file);

      await fetch(
               method: 'POST',
               body: formData,
                   // 'Authorization': "Bearer " + "139|qMtIApnGoPFxPGrEXGzKSEWTbbXrHXCAU5uuTar3"
                   'Authorization': 'Bearer ' + user.token,
           .then((response) => response.json())
           .then((result) => {
               console.log('Success:', result);
                   // icon: 'success',
                   title: 'Data Saved Successfully'
           .catch((error) => {
               console.error('Error:', error);
                   // icon: 'error',
                   title: 'All Field required',
                   text: error.text,


   return (

           <div className="col-sm-6 offset-sm-3 my-4">
               <h1 className="text-center">AddService</h1>
               <input type="text" onChange={event => setName(event.target.value)} placeholder="
                   Service Name" className="form-control" required="" />
               <br />
               <input type="text" onChange={event => setDesc(event.target.value)} placeholder="Service Description" className="form-control" />
               <br />
               <input type="file" onChange={event => setFile(event.target.files[0])} className="form-control" />
               <br />
               <button onClick={Addservice} className="btn btn-primary">Save</button>


export default Addservice

const user = JSON.parse(localStorage.getItem(‘token’));

We already set token, here we only get the token and set it into header


The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

                   // 'Authorization': "Bearer " + "139|qMtIApnGoPFxPGrEXGzKSEWTbbXrHXCAU5uuTar3"
                   'Authorization': 'Bearer ' + user.token,

Thanks for reading…



Leave a Reply

Your email address will not be published.