472,794 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

script for multiple file upload/attachment in web form

Hi,
I am looking for script to allow multiple files can be
uploaded/attached in webform ( mostly cgi/perl or php).

But I don't like the multiple input boxes using "<input type="file"
size="40" maxlength="40" name="filename[]">" html tag. As it will
limit the no. of files can be uploaded(only as many of this boxes I
write in form & doesn't look good in form also).

I am looking for multiple file upload in web form using "select" or
"textarea" html tags. So I can upload/attach multiple files without
limit, every attached file will be kept in "textarea/list", than
processed on submit button call.

Can any one suggest where this script can be found, I googled..., but
no luck over there.

Thanks,
Avin Patel
Jul 23 '05 #1
1 5438
Avin Patel wrote:
I am looking for multiple file upload in web form using "select" or
"textarea" html tags. So I can upload/attach multiple files without
limit, every attached file will be kept in "textarea/list", than
processed on submit button call.


This isn't going to work. <input type="file" ...> is "special". When the
browser posts the form, it knows to take the contents of the file pointed
to by that form control and send it to the server. The browser has no way
of knowing what to do with a list of files in a <select> or <textarea>.

What you _can_ do, in modern browsers at least, is to let the user "add"
as many <input type="file" ...> inputs as they require:

<script type="text/javascript">
function addFile(b) {
if (b && b.parentNode &&
b.parentNode.insertBefore &&
document.createElement) {

var fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.name = 'filename[]';

b.parentNode.insertBefore(fileInput, b);

b.parentNode.insertBefore(document.createElement(' br'), b);
}
}
</script>
<form name="myForm" method="post" enctype="multipart/form-data">
<input type="file" name="filename[]">
<br>
<input type="button" value="Add another file" onclick="addFile(this);">
</form>

It adds the inputs in IE 6SP1, Firefox 0.10.1 and Opera 7.54. I don't
know if it properly submits the filename controls (because they are all
named the same, and have [] in them). If it doesn't work as is, it would
probably work if you gave each input a unique name:

fileInput.name = 'filename' + (one plus the last filename added);

Obviously that's psuedo-code, obtaining the next filename input name
could involve a global variable, or possibly querying the form to obtain
the value of the last filename input.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #2

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

Similar topics

2
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug....
10
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
1
by: sohail28 | last post by:
Respected Sir /Madam, I create one web page which includes online reservation using phpscript. Now this page is working fine, but it executes on the same page. i want here, when i click...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.