[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Browse for File, capture filename, do not upload file

Posted on 2007-11-16
2
Medium Priority
?
713 Views
Last Modified: 2010-04-21
I need a file browse feature added to my web site.  Similar to the <input type="file"> feature, but it will only capture the name of the file and insert it into a text field on the form.  It SHOULD NOT attempt to upload the file to the web server when the form is submitted.
0
Comment
Question by:benlane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
den4b earned 2000 total points
ID: 20298831
You can use javascript on your submit button to extract the filename and remove the FILE element from the page. The sample code is shown below:
<html>
<head>
  <script>
    function extract_file_name()
    {
      var file = document.getElementById('file');
	  if (!file) return false;
      var filename = file.value; 
      file.parentNode.removeChild(file);
      var pos = filename.lastIndexOf('\\');
      if (pos >= 0) filename = filename.substring(pos+1, filename.length);
      return filename;
    }
  </script>
</head>
<body>
  <input id="file" type="file"><br><br>
  <button onclick="alert(extract_file_name())">Extract File Name</button>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:benlane
ID: 31409562
Thanks a lot!  Worked Great!
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question