CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Posts
    4

    how to get the url of a folder.. urgently need help

    hi guys,, need ur help....

    i facing some problem. at first i thought it was a html problem but my frenz tell me it can be done using javascript.
    that y i hope by posting here can help me...

    i know <input type=file name=try> will display a textbox wif a "browse"btn tat allow user to select a particular file n return the entire path of the file selected in the textbox.

    however, now i want to allow user to select a folder only and return the entire path of the folder.

    therefore the output in the textfield should be
    c:\my document\abc\
    instead of
    c:\my document\abc\text.html


    can anyone tell me how to do so? i need the answer urgently...

  2. #2
    Join Date
    Apr 2001
    Location
    Salt Lake City, UT
    Posts
    135
    I don't know how you could easily do this with JavaScript, but it would be very easy using VBScript. The only problem with that is VBScript only works in IE (client-side).
    If you are doing server-side scripting (ASP page using VBScript) then I can give you simple way to do this using the FileSystemObject.
    Let me know exactly how your page is setup (HTML/JavaScript or ASP/VBScript) & I'll see what I can do.

  3. #3
    Join Date
    Jun 2002
    Posts
    4
    thanks a lot...
    but i dun know whether vbscript will work for me a not..
    actually my coding is using jsp( java server page).
    i use pure html with javascript.. in a form which i post it to a jsp file to do the backend servicing.
    i m using tomcat webserver 3.3.1.
    so can vbscript be like javascript tat can be executed in jsp pages..

    thanks for replying.. hope u can reply me soon..

  4. #4
    Join Date
    Jan 2002
    Location
    Helsinki, Finland
    Posts
    99
    Guess this is what you're after :
    Code:
    <!-- Example Written by Zvona -->
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    	<head>
    		<title>Parsing a folder</title>
    		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
    		<script type="text/javascript">
    		<!--
    		function getFolderNames(oForm)
    		{
    			var iA		= 0;
    			var aInputF	= new Array();
    			var aReturnVal	= new Array();
    			for (var iI=0;iI<oForm.length;iI++)
    			{
    				if (oForm.elements[iI].type == "file")
    				{
    					aInputF[iA] = oForm.elements[iI];
    					iA++;
    				}
    			}
    
    			for (var iI=0;iI<aInputF.length;iI++)
    			{
    				if (aInputF[iI].disabled || aInputF[iI].value == "")
    					aReturnVal[iI] = "No folder";
    				else
    					aReturnVal[iI]	= aInputF[iI].value.substring(0,aInputF[iI].value.lastIndexOf("\\"));
    			}
    
    			return aReturnVal;
    		}
    		// -->
    		</script>
    	</head>
    
    	<body>
    		<form action="">
    		<table border="0">
    			<tbody>
    				<tr>
    					<td><input type="file" /></td>
    				</tr>
    				<tr>
    					<td><input type="file" /></td>
    				</tr>
    				<tr>
    					<td><input type="file" /></td>
    				</tr>
    				<tr>
    					<td><input type="button" value="getFolderNames()" onclick="alert(getFolderNames(this.form));" /></td>
    				</tr>
    			</tbody>
    		</table>
    		</form>
    	</body>
    </html>
    Tested with NN4.7 & IE6. Blue function is the one you need. It returns the value in an array.
    Zvona - First aid for client-side web design

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured