GetTempName method of Javascript FileSystemObject (FSO) is another interesting function that provides the functionality to generate random temporary file name to store temporary data at client’s machine. FSO GetTempName method generates a new temporary name each time when it is called inside the javascript code. GetTempName method returns the filename with “.tmp” file extension that has no association with any of the windows’ application.
Syntax for Javascript FSO GetTempName method
fso.GetTempName();
FSO GetTempName method does not take any parameter. It just randomly generates a new temporary file name each it is called in the code.
Example of FSO GetTempName method
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// returns the randomly generated temporary file name
var fTempName = fso.GetTempName();
document.write(fTempName);
document.write("<br />");
fso = null;
// Output:
// rad39F67.tmp
</script>
Continue to next tutorial: Javascript FSO MoveFile Method to learn how to move the file from one location to another.