Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

image uploading using formdata

export async function newDocUpload(
    access_token: string,
    question_id: any,
    upload_type:any,
    file:any,
    type:any,
    id:any,
) {
  const url = `${server_url}/rm/upload/doc/`;
  const formdata = new FormData()
  formdata.append('question_id',question_id);
  formdata.append('upload_type',upload_type);
  formdata.append('new_document_file',file);
  formdata.append('type',type);
  formdata.append('id',id);
    try {
    const response = await axios({
        method: "post",
        url: url,
        data:formdata,
        headers: {
            Authorization: `Bearer ${access_token}`,
          },
      });
    return response.data;
Comment

FormData upload file

const form = document.getElementById('form');
const formData = new FormData(form);

const output = document.getElementById('output');

for (const [key, value] of formData) {
  output.textContent += `${key}: ${value}
`;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to add multiple style attributes in react element 
Javascript :: arguments in javascript 
Javascript :: javascript object declaration 
Javascript :: javascript xhr set parameters 
Javascript :: Function.prototype.bind polyfill 
Javascript :: add a string regex in angular input 
Javascript :: link externo no react 
Javascript :: react-app-rewired test single file 
Javascript :: javascript code to test if screen is idle 
Javascript :: remove last element from an array 
Javascript :: basic react code 
Javascript :: angular blockly 
Javascript :: how to clear all slash commands 
Javascript :: div goind down 
Javascript :: modulenamemapper not working 
Javascript :: nested arrays javascript 
Javascript :: rotate13 text in javascript 
Javascript :: nuxt history back 
Javascript :: convert string to integer javascript 
Javascript :: axios.get Uncaught (in promise) TypeError: response.json is not a function 
Javascript :: make id of certain length js 
Javascript :: how to remove letters from an array javascript 
Javascript :: node is not recognized as internal command 
Javascript :: find saturday with moment js 
Javascript :: javascript Use clearTimeout() Method 
Javascript :: custom search filter in angular 8 
Javascript :: js closure 
Javascript :: sort array javascript 
Javascript :: hover on child from parent mui react 
Javascript :: how to write a function in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =