Get the input value of the uploaded file directly

Source: Internet
Author: User

JS function
  
 
  1. <script>
  2. function m(i){
  3. var url=i.value;
  4. url=url.split("\\");
  5. var n = url[url.length-1];
  6. n = n.substring(0,n.lastIndexOf(‘.‘));
  7. document.getElementById(‘title‘).value = n;
  8. }
  9. </script>
  
 
  1. 资质描述<input type="text" name="ztitle" id="title"><br>
  2. 资质上传<input type="file" name="zzfile" onChange="m(this)"><br>
Fill in the qualification description with the file name of the qualification upload directly
  
 
  1. <!doctype html>
  2. <meta charset="utf-8">
  3. <title>无标题文档</title>
  4. <body>
  5. 企业荣誉资质
  6. <form action="zzsave.php" method="post" enctype="multipart/form-data">
  7. 类别:<select name="cname">
  8. <?php
  9. include ‘../inc/db_mysqli.php‘;
  10. $rows=query(‘hnsc_zzclass‘);
  11. foreach($rows as $v){
  12. printf("<option value=‘%s‘>%s</option>",$v[0],$v[0]);
  13. }
  14. ?>
  15. </select>
  16. <button onClick="location.href=‘zzclassadmin.php‘;">新增类别</button><br>
  17. qualification description <input type = "text" name = "Ztitle" id = "title" ><BR>
  18. 资质上传<input type="file" name="zzfile" onChange="m(this)"><br>
  19. 是否在网站上显示
  20. < Label><input type = "Radio" name = Span class= "ATV" > "flag" value = "y" checked > show </LABEL>
  21. <label><input type="radio" name="flag" value="n">不显示</label><br>
  22. <input type="submit" value="提交">
  23. <script>
  24. function m(i){
  25. var url=i.value;
  26. url=url.split("\\");
  27. var n = url[url.length-1];
  28. n = n.substring(0,n.lastIndexOf(‘.‘));
  29. document.getElementById(‘title‘).value = n;
  30. }
  31. </script>
  32. </form>
  33. </body>





From for notes (Wiz)

Get the input value of the uploaded file directly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.