Hy all !! i want to upload Image file in file cabi...
# suitescript
h
Hy all !! i want to upload Image file in file cabinet through external html application (SSP Application) i have tried HTML FILE CODE
var file_data = $('#attachFile' + i).prop('files')[0];
 
var form_data = new FormData();
form_data.append('file', file_data);
and then post form_data Restlet CODE
var file = valuesArray[i].file;
here i tried to stringify file object the result i got
"{}"
this
file.setFolder(199); //*Error is here Cannot find set.folder function*
var id = file.save();
but after giving my all efforts file is not saving in file cabinet ! Does anyone have idea on this?
n
you need to do file.create then set the content and folder properties as well as other properties. take a look in help at file.create.
h
TypeError: Cannot find function create in object [object Object].
now i am getting this error @NElliott
n
Please post your full code including the change. you have made. You did reference the help for the N/file module too right? @humzariaz
if you still have this: var file = valuesArray[i].file; then that's your issue since you've potentially overwritten the n/file instance.
h
@NElliott could you plz share with me how can i make img object in ssp javascript and post to restlet ! i am using this code to make img object HTML
var imagebase64;
var file_data = $('#attachFile' + i).prop('files')[0];
var reader = new FileReader();
  
reader.onloadend = function() {
  
imagebase64 = reader.result;
  
console.log(imagebase64);
}
    
reader.readAsDataURL(file_data);
`innerobj["file"] = imagebase64`; and yhen this is how i am pushing into object and post to netsuite
RESTLET
var file = valuesArray[i].file;
                
log.debug({
                    
title: 'Debug Entry',
                      
details: 'Value of img is: ' + JSON.stringify(file)
                    
});
                
var fileObj = file.create({
                    
name: 'test.png',
                    
fileType: file.Type.PNGIMAGE,
                    
contents: file,
                    
isOnline: true
                
});
                
fileObj.setFolder(199);
                
var id = fileObj.save();
issue in img Object creation i found nothing in log.debug in restlet !!