Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1698 How can I extract just the extension file name from a forms file upload field?

You are here: irt.org | FAQ | JavaScript | Form | Q1698 [ previous next ]

Try:

<html>

<head>

<script language="JavaScript"><!--
function getExtension(value) {
  return value.substring(value.lastIndexOf('.') + 1,value.length);
}
//--></script>

</head>

<body>

<form>
<input name="myFile" type="file">
<input type="button" value="Extract" onClick="alert(getExtension(this.form.myFile.value))">
</form>

</body>

</html>

©2018 Martin Webb