Sometimes the file name needs to be captured on the page. I can see a good instance on the Internet and share it with you. Thanks to the original author.
Code:
- <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <HTML xmlns = "http://www.w3.org/1999/xhtml">
- <Head>
- <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
- <Meta name = "keywords" content = "simple XHTML page"/>
- <Meta name = "Description" content = "this is a simple XHTML page"/>
- <Title> simple XHTML page </title>
- </Head>
- <Body>
- <Script language = "JavaScript">
- Function Test (){
- VaR str1 = Document. form1.filefile1. value;
- VaR regstr = ////;
- VaR regresult = new Regexp (regstr)
- VaR SSS = str1.split (regresult, '123 ');
- VaR need = SSS [sss. Length-1];
- VaR A = need. Split ('.');
- Document.form1.txt text2.value = A [0];
- Document.form1.txt text3.value = A [1];
- }
- </SCRIPT>
- <Body>
- <Form name = form1>
- File input: <input name = filefile1 type = File> <br>
- Text1: <input name = txttext1 type = "text" size = 60> <br>
- Text2: <input name = txttext2 type = "text"> <br>
- Text3: <input name = txttext3 type = "text"> <br>
- <Input type = "button" value = "test" onclick = "txttext1.value = filefile1.value"> <br>
- <Input type = "button" value = "convert" onclick = "test ()">
- </Form>
- </Body>
- </Body>
- </Html>
From: http://www.cnblogs.com/JustinYoung/articles/969900.html