Yeah, just set a maxUploads variable to the number you want and wrap
everything inside the function in an if statement. Something like...
var maxUploads = 3;
if (document.imgform.fldCount.value == maxUploads)
{
alert('already at the max number');
}
else
{
//ALL THE REST OF THE CODE HERE
}
..:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
-----Original Message-----
From: Andy Matthews [mailto:[EMAIL PROTECTED]
Sent: Monday, August 28, 2006 11:53 AM
To: CF-Talk
Subject: RE: Uploading X number of photos at one time?
Sorry that I didn't respond to this post. Is it possible to limit the amount
of upload fields the user can add?
<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->
-----Original Message-----
From: Bobby Hartsfield [mailto:[EMAIL PROTECTED]
Sent: Friday, August 25, 2006 9:24 PM
To: CF-Talk
Subject: RE: Uploading X number of photos at one time?
Paste all of this in a .html file and run it. Click the [Add another Image
Uploader] link to add more fields. I would of course limit this to a maximum
number of images at once. (way less than 10) To upload multiple images at
one time without worrying about timeouts youll have to look into something
like ActiveX controls
<script>
function addFieldSet()
{
//Increment the field counter
thisInc = Number(document.imgform.fldCount.value) + 1;
document.imgform.fldCount.value = thisInc;
//Build the div container
divCont = document.createElement('DIV');
divCont.id = 'img' + thisInc;
divCont.style.background='ececec';
divCont.style.borderStyle = 'solid';
divCont.style.borderWidth = '1px';
divCont.style.borderColor = '000000';
//Build the table element
thisTable = document.createElement('TABLE');
thisTable.border = '0';
thisTable.cellPadding = '5';
thisTable.cellSpacing = '0';
thisTable.width = '100%';
//Build the first row of the table
Row1 = document.createElement('TR');
//Build column 1 of the first row
Row1Col1 = document.createElement('TD');
Row1Col1.innerHTML = 'Image File:';
//Buld column 2 of row 1
Row1Col2 = document.createElement('TD');
//Build the file field
fileFld = document.createElement('INPUT');
fileFld.type = 'file';
fileFld.name = 'imagefile' + thisInc;
fileFld.size = '40';
//Build a span tag to hold some text and a line break just
after the file field
thisSpan1 = document.createElement('SPAN');
thisSpan1.innerHTML = '<br>valid formats: jpg, jpeg, pjpeg,
gif';
//Put the file field and text in the column
Row1Col2.appendChild(fileFld);
Row1Col2.appendChild(thisSpan1);
//Go ahead and put the first row all together.
Row1.appendChild(Row1Col1);
Row1.appendChild(Row1Col2);
//Build the second row
Row2 = document.createElement('TR');
//Build the columns just as before but (of course) with
different text and a textarea field
Row2Col1 = document.createElement('TD');
Row2Col1.vAlign = 'top';
Row2Col1.innerHTML = 'Cutline:';
//Build column 2 of row 2
Row2Col2 = document.createElement('TD');
Row2Col2.vAlign = 'top';
//build the text area
txtArea = document.createElement('TEXTAREA');
txtArea.name = 'cutline' + thisInc;
txtArea.cols = '40';
txtArea.rows = '2';
//Add the textarea to column 2 of row 2
Row2Col2.appendChild(txtArea);
//Add the columns to the row
Row2.appendChild(Row2Col1);
Row2.appendChild(Row2Col2);
//Create t tbody to hold the table content
thisTbody = document.createElement('TBODY');
//Add the rows to the table
thisTbody.appendChild(Row1);
thisTbody.appendChild(Row2);
//Add the TBODY to the table
thisTable.appendChild(thisTbody);
//Now add the table to the div
divCont.appendChild(thisTable)
//Finally, add the div to the main div container
document.getElementById('FormFieldContainer').appendChild(divCont);
//And add a line break after the div
document.getElementById('FormFieldContainer').appendChild(document.createEle
ment('BR'));
}
</script>
<form name="imgform" action="index.cfm?action=upimgs&imgid=0" method="post"
enctype="multipart/form-data" style="display:inline; ">
<input type="hidden" name="fldCount" value="1" />
<div id="FormFieldContainer">
<div align="right"><a href="javascript:void(0);"
onClick="addFieldSet();return false;">[Add Another Image Uploader]</a></div>
<br>
<br>
<div id="img1" style="background:#ececec;border:1px solid #000000;">
<table border="0" cellpadding="5" cellspacing="0"
width="100%">
<tr>
<td>Image File: </td>
<td>
<input type="file" name="imagefile1"
size="40"><br>
valid formats: jpg, jpeg, pjpeg, gif
</td>
</tr>
<tr>
<td valign="top">Cutline: </td>
<td><textarea name="cutline1" cols="40"
rows="2"></textarea></td>
</tr>
</table>
</div>
<br>
</div>
<div style="background:#ececec;border:1px solid #000000;padding:3px;">
<input type="submit" name="Uploadimg" value="Upload Image">
</div>
</form>
....:.:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/427 - Release Date: 8/24/2006
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:251307
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4