# Save File Script Help

**URL:** <https://forum.inductiveautomation.com/t/save-file-script-help/5073>\
**Category:** Ignition\
**Created:** [August 29, 2012, 7:55pm UTC](https://forum.inductiveautomation.com/t/save-file-script-help/5073 "2012-08-29T19:55:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlr573](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jlr573](https://forum.inductiveautomation.com/u/jlr573)\
**Post date:** [August 29, 2012, 7:55pm UTC](https://forum.inductiveautomation.com/t/save-file-script-help/5073/1 "2012-08-29T19:55:39Z")

</div>

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?

```auto
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")
	system.gui.messageBox("Saved")
```

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.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [August 29, 2012, 8:06pm UTC](https://forum.inductiveautomation.com/t/save-file-script-help/5073/2 "2012-08-29T20:06:14Z")

</div>

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]`
