Save File Script Help

I’m using the system.file.saveFile to save a file to a location on the server. It already returns the file path but is there a way to pull out what the user typed for a file name?

openFilePath = system.file.openFile()
fileSaveTarget = system.file.saveFile(openFilePath)
docName = fileSaveTarget
compID = event.source.parent.getComponent('tblCompList').comp_id
pathID = 1
dwgTable = event.source.parent.getComponent('tblDwgList')
compTable = event.source.parent.getComponent('tblCompList')
docTable = event.source.parent.getComponent('tblDocuments')

if openFilePath != None:
	bytes = system.file.readFileAsBytes(openFilePath)
	system.file.writeFile(fileSaveTarget, bytes)
	system.db.runPrepUpdate("INSERT INTO doc_list (doc_name, comp_id, path_id) VALUES (?,?,?)", [docName, compID, pathID])
	system.db.refresh(docTable, "data")

What I’m doing is allowing the user to pick a file they what to tie to a record in the database and then store the file in a different location on the server and we are managing the file paths. I know this can be done by creating a BLOB data type but that option doesn’t work for how this project has to be setup.

The file name should just be the last part of the path. If you want to get that out just do the following:paths = fileSaveTarget.split("\\") fileName = paths[len(paths)-1]