'how can upload image and video with cloudinary

const Profile = () => {
  
  const [file, setFile] = useState("");

  const send = async (event) => {
    const data = new FormData();
    data.append("file", file);
    data.append("upload_preset", "*****");
    await axios
      .post("https://api.cloudinary.com/v1_1/*****/upload", data)
      .then((res) => console.log(res));
     .catch((err)=>console.log(err)) console.log(data)
  };

  return (
    <div className="card" style={{ marginTop: "20px", width: "500px" }}>
      <form action="#">
        <input
          type="file"
          onChange={(event) => {
            const file = event.target.files[0];
            setFile(file);
          }}
        />
      </form>
      <button onClick={send}>Upload</button>
    </div>
  );
};

export default Profile;

I want to upload images and videos with culinary, I tried in my app but the error network but in another app, it works with the same code



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source