Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

image base64 to file javascript

 function dataURLtoFile(dataurl, filename) {
 
        var arr = dataurl.split(','),
            mime = arr[0].match(/:(.*?);/)[1],
            bstr = atob(arr[1]), 
            n = bstr.length, 
            u8arr = new Uint8Array(n);
            
        while(n--){
            u8arr[n] = bstr.charCodeAt(n);
        }
        
        return new File([u8arr], filename, {type:mime});
    }
    
    //Usage example:
    var file = dataURLtoFile('data:text/plain;base64,aGVsbG8gd29ybGQ=','hello.txt');
    console.log(file);
Comment

PREVIOUS NEXT
Code Example
Javascript :: netlify not deploying react site 
Javascript :: how i change background of row in javascript jquery 
Javascript :: how to apply scrollbar in textarea 
Javascript :: why in the hell does JavaScript - Date getMonth() return 11 
Javascript :: react document documentMode not found 
Javascript :: Discord.js v12 member voiceChannel 
Javascript :: does script defer keep order 
Javascript :: how to add carsoul to react project 
Javascript :: Baris (Record/Tuple adalah] 
Javascript :: disable pdf download javascript 
Javascript :: get call log in react native android 
Javascript :: 11 connection listeners added to [Namespace]. Use emitter.setMaxListeners() to increase limit 
Javascript :: gsheet calculate next tuesday date 
Javascript :: moment js days ago 
Javascript :: map vs subscribe angular 
Javascript :: The behavior that Selection.addRange() merges existing Range and the specified Range was removed. 
Javascript :: como usar for js 
Javascript :: formatDuration js 
Javascript :: rxjs fromevent mouseover 
Javascript :: alpiee js hide amother button click 
Javascript :: react native Stack Navigation Prop unused variable 
Javascript :: how to only register one click on nested component and not parent component in react js 
Javascript :: javascript reflections iterate all members 
Javascript :: enum in javascript es6 
Javascript :: expressjs cors blocked mixed-content 
Javascript :: form api 
Javascript :: supabase realtime connection 
Javascript :: Vuex body skeleton 
Javascript :: release mouse key javascript 
Javascript :: jquery textfill example 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =