and this is the code
/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
// possible option is to create a Suitelet with a Document field and save the
// file uploaded to that field. Here's the code for such a Suitelet:
define(['N/ui/serverWidget'],
function(serverWidget) {
function onRequest(context) {
if (context.request.method === 'GET') {
// creating form
var form = serverWidget.createForm({
title: 'Form to write file'
});
// add field
var field = form.addField({
id: 'custpage_file',
type: 'file',
label: 'Document'
});
form.addSubmitButton({
label: 'Submit Button'
});
context.response.writePage(form);
}
else {
var fileObj = context.request.files.custpage_file;
fileObj.folder = 293909; //replace with own folder ID
var id = fileObj.save();
}
}
return {
onRequest: onRequest
};
});