Uploading csv files for import into database

Hiya,
I was wondering whether it’s possible to set up a csv/xls(x) file upload in TiNG, that automatically processes all of data within the file for whichever table you select in the database.

I have set up a servoy extra - file upload component but am not sure what the accept value should be for .csv files. I have a rough idea about how I would go about processing the data once it’s been uploaded, but am unsure about how to get the data post upload.

Thanks!
Alasdair

Hi Alasdair,

You can just do something like this:

function onActionUpload(event, dataTarget) {
	plugins.file.showFileOpenDialog(callbackUploadFile);
}

/**
 * @param {Array<plugins.file.JSFile>} _aFiles
 */
function callbackUploadFile(_aFiles) {
	if(!_aFiles.length) {
		return;
	}
	
	// process the file(s)
}

So you will click a button that will have the onAction function attached.
Once the user uploads the file, the callback function will be called and you can process the file like you have in mind.

Hope this helps