Skip to content

Commit

Permalink
Step 3: Uploading form file to Cloudinary
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed Jul 27, 2023
1 parent 87052bb commit cf589a4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages/contact.tsx
Expand Up @@ -17,6 +17,19 @@ function Contact() {

async function handleOnSubmit(e: React.SyntheticEvent) {
e.preventDefault();

if ( typeof file === 'undefined' ) return;

const formData = new FormData();

formData.append('file', file);
formData.append('upload_preset', 'test-react-uploads-unsigned');
formData.append('api_key', import.meta.env.VITE_CLOUDINARY_API_KEY);

const results = await fetch('https://api.cloudinary.com/v1_1/colbycloud-examples/image/upload', {
method: 'POST',
body: formData
}).then(r => r.json());
}

function handleOnChange(e: React.FormEvent<HTMLInputElement>) {
Expand Down

0 comments on commit cf589a4

Please sign in to comment.