473,770 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

input file-multi file, directory

For the <input type="file">, can I select directory? Multiple directories?

Thanks,

qq
Jul 23 '05 #1
2 2980
Ivo
"Quick Function" wrote
For the <input type="file">, can I select directory?
I 'm afraid not. You cannot even be sure of the existence of a particular
directory on other systems.
Multiple directories?


All at once??
Jul 23 '05 #2
Quick Function wrote:
For the <input type="file">, can I select directory? Multiple directories?

Thanks,

qq


As mentioned, you can not select multiple files or directories using <input
type="file">. As a result, another solution is necessary. The following will
only work in the most modern of browsers (IE6SP1, Gecko-based browsers, Opera
7.53, perhaps others you will need to test):

<script type="text/javascript">
function anotherFile(lnk ) {
if (document.creat eElement &&
lnk.insertBefor e &&
lnk.parentNode) {

var finp = document.create Element('input' );
var brk = document.create Element('br');
if (finp && brk) {
finp.type = 'file';
finp.name = 'file' + (new Date()).getTime () + Math.floor(100 *
Math.random());
lnk.parentNode. insertBefore(fi np, lnk);
lnk.parentNode. insertBefore(br k, lnk);
}
}
return false;
}
</script>
<form name="myFormNam e" id="myFormId">
<input type="file" name="file1">
<br>
<a href="#" onclick="return anotherFile(thi s);">Another File</a>
</form>

Notes:

- "(new Date()).getTime () + Math.floor(100 * Math.random())" is intended to
generate a unique form element name. This should not present much of a problem
on the server, most server-side technology has something like
Request.subkeys ("file") that allows you to find all inputs that start with a
particular string. The other ways to do this is have a global variable that
gets incremented to produce "file2", "file3", etc.

- The code as written depends on the "Another File" link coming after the
<input>. This allows the use of insertBefore() to add another file input. The
other possibilities would be to have a dummy <span> under the last input as a
marker to insertBefore(), or simply appendChild() on the <form>.

- As already mentioned this only works in the most modern browsers.

- I haven't actually tested this to upload files. Some browsers may have a
problem actually submitting form inputs added to the form using
insertBefore().

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2766
by: gotcha | last post by:
I have a little code to add multiple items to a shopping cart based page. This code works perfect, but it adds all of the info to the same input fields every time it loops. I need it to change the input names each time it loops. Here is the code. <% FOR x = 0 TO UBOUND( localCart, 2 ) IF localCart( CARTPID, x ) <> "" THEN orderTotal = orderTotal + ( localCart( CARTPPRICE, x ) * localCart ( CARTPQUANTITY, x ) )
3
2570
by: david | last post by:
HI! Im trying to make "HTML form" into automatic. 1. If I get 18 numbers like: A B C D E F . . . . 2. How can I put those 18 numbers automatically into 6 numbers format like: A B C D E F
3
5177
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form within the html document. When the Finish button is clicked, I need to check for any empty input boxes before loading the next aspx page...but it could be no boxes or five boxes, etc.? I've included my html output...if you have any ideas,...
12
2315
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type text,text,radio,checkbox and select. When I run the following code, it correctly reports "text" (for input
3
2846
by: Fao, Sean | last post by:
Hello all, As stated in another message, it's been a long time since I've done any C coding and I'm not feeling comfortable that I'm doing this correctly. Basically, I'd like to verify that my supplied input is alphanumeric. White space and opening/closing parenthesis are also permitted. Nothing more, nothing less. Additionally, despite having read my documentation for scanf(), I'm uncertain how --if it's even possible-- to have a...
2
3108
by: Cranky | last post by:
Ok, here is my scenario: I need to input numbers using my handheld IPAQ. I figured out how to create an online numeric keypad for inputting numbers into an input field, what I need to know is how I can have JS switch from one input field to another based on me clicking in the empty box. Here is my code: ########## Start of code ################### <html> <head>
3
4011
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table with a createElement function to add additional entries. The table has the first row of input text boxes already in it. You have to click a button to add another row. That seems to be working fine. How do I pull the information from the input boxes...
3
4824
by: cbradio | last post by:
Hi, I am having trouble developing a form in a restricted environment. My sample code is found below my message (sorry I don't have a URL). Basically, without a doctype, the form displays properly with 3px padding around each form field, and no overlap. But the doctype changes the box model, I am told, and so the padding is added to the 100% width, leading to overlap and poor presentation. Unfortunately, I'm forced to use the doctype due to...
18
25006
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin, that IE7 does not seem to offer any way to control the font size of a text input element.
3
2085
by: manxie | last post by:
Dear All Readers, I'm supposed to create a program with a switch and using voids to execute number of codes, that includes finding sum, average, maximum, and minimum, please read my code: #include <iostream> #include <string> #include <iomanip> using namespace std; void WELCOME();
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.