Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form | Q1698 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.