Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

formdata append not working

$('#upload-image').change(function(e) {
    var file = e.target.files[0];
    var imageType = /image.*/;

    if (!file.type.match(imageType)) return;

    var form_data = new FormData();
    form_data.append('file', file);

    for (var key of form_data.entries()) {
        console.log(key[0] + ', ' + key[1]);
    }

    $.ajax({
        url: 'http://localhost/upload.php',
        cache: false,
        contentType: false,
        processData: false,
        data: form_data,
        type: 'POST',
        success: function(response) {
            console.log(response);
        },
        error: function(error) {
            console.log(error);
        }
    });

});
Comment

PREVIOUS NEXT
Code Example
Javascript :: on load page javascript 
Javascript :: javascript get sub array 
Javascript :: alpinejs with select 
Javascript :: async import javascript 
Javascript :: js check if array of dictionaries contain 
Javascript :: how to show progress on ajax call 
Javascript :: next js image 
Javascript :: js filter out doubles 
Javascript :: discord.js.Client 
Javascript :: import js in jupyter notebook 
Javascript :: how to create a folder using fs in node js 
Javascript :: adding element to javascript object 
Javascript :: how to download file from link in react 
Javascript :: mongodb mongoose update an element in an array of objects 
Javascript :: jquerry in bootstrap 
Javascript :: momentjs format date 
Javascript :: sort js 
Javascript :: header disallowed by preflight response in express 
Javascript :: include js to js 
Javascript :: body-parser deprecated 
Javascript :: express req get json 
Javascript :: png to base64 javascript 
Javascript :: contains duplicate leetcode solution javascript 
Javascript :: link to another page and achor react 
Javascript :: vuejs get value of checkbox group 
Javascript :: upload image to firebase 
Javascript :: searching in json array mongodb 
Javascript :: convert arrow function to normal function javascript 
Javascript :: random positive or negative javascript 
Javascript :: js increment and decrement function for cart 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =