Forum Moderators: coopster
Its an unlimited upload script, you decide how many images you want to upload, and a while loop draws the file boxes, then you fill the boxes the usual way and then the $_post and mysql is in a while loop to collect and insert the images into a db, images are also stored into the correct folders on the server.
Im sure this can be done other ways but i spent ages making something too complicated until realising that a simple solution usually works best ;)
so here we go,
page one :
<?
//start here
$client = $_POST['client'];
$amount = $_POST['amount'];
if ($amount == "Enter amount here"){
$amount = 0;
}
$num = $amount;
?>
then in the body
<p align="center"><br />
UPTO 180,000 images in one click </p>
<form action="" method="post" name="form1" target="_self" class="normal_text" id="form1">
How many images would you like to upload?<br />
<br />
<input name="amount" type="text" class="boxes" id="amount" value="Enter amount here" onfocus="this.value=''" />
<input name="Submit" type="submit" class="boxes" value="Submit" />
<input name="client" type="hidden" id="client" value="<? echo "$client"?>" />
</form>
<form action="members_client_pic_upload_do.php" method="post" enctype="multipart/form-data" name="form2" id="form2">
<br />
<span class="normal_text">This is where you choose your files to upload, the submit button is at the end of the list.</span><br />
<br />
<table width="560" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="195" class="style3">Small image </td>
<td width="162" class="style3">Large image </td>
<td width="117" class="style3">Image type </td>
<td width="76" class="style3"><div align="center">Include Pic </div></td>
</tr>
</table>
<?
$i = 0;
while ($i<$num){
?>
<table width="560" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="175"><input name="image_small_<? echo "$i"?>" type="file" class="boxes" id="image_small_<? echo "$i"?>" size="10" /></td>
<td width="171"><input name="image_big_<? echo "$i"?>" type="file" class="boxes" id="image_big_<? echo "$i"?>" size="10" /></td>
<td width="72"><select name="cat_<? echo "$i"?>" class="boxes" id="cat_<? echo "$i"?>">
<option>Category N/A</option>
<option value="functions">Functions</option>
<option value="weddings">Weddings</option>
<option value="Commercial">Commercial</option>
<option value="portrait">Portrait</option>
<option value="people">People</option>
<option value="architecture">Architecture</option>
<option value="nature">Nature</option>
<option value="food">Food</option>
<option value="clothing">Clothing</option>
<option value="products">Products</option>
<option value="other">Other</option>
</select></td>
<td width="72"><div align="center" class="normal_text">
<input name="include_<? echo "$i"?>" type="checkbox" id="include_<? echo "$i"?>" value="1" />
<span class="question" title="Click this box to include this image, this prevents blank images being uploaded.">[?]</span></div></td>
</tr>
</table>
<p>
<?
++$i;
}
}
?>
<input name="Submit2" type="submit" class="boxes" value="Upload all" />
<input name="client" type="hidden" id="client" value="<? echo "$client"?>" />
<input name="amount" type="hidden" id="amount" value="<? echo "$amount"?>" />
</p>
</form>
// FOLLOWED by page two
//start here
$clientid = $_POST["client"];
$amount = $_POST["amount"];
//debugging
//echo "$clientid - $amount<p>";
$x = 0;
while ($x<$amount){
//-files1----------------------------------------------------------------------------------------------
move_uploaded_file($_FILES["image_small_$x"]['tmp_name'],'images/members/'.$username.'/'.$clientid.'/thumb/'.$_FILES["image_small_$x"]['name']);
$image_thumb = $_FILES["image_small_$x"]['name'];
//-----------------------------------------------------------------------------------------------------
//-files2----------------------------------------------------------------------------------------------
move_uploaded_file($_FILES["image_big_$x"]['tmp_name'],'images/members/'.$username.'/'.$clientid.'/big/'.$_FILES["image_big_$x"]['name']);
$image_big = $_FILES["image_big_$x"]['name'];
//-----------------------------------------------------------------------------------------------------
//-files3----------------------------------------------------------------------------------------------
//move_uploaded_file($_FILES["image_super_$x"]['tmp_name'],'images/uploads/personal/super/'.$_FILES["image_super_$x"]['name']);
//$image_super = $_FILES["image_super_$x"]['name'];
//-----------------------------------------------------------------------------------------------------
$image_title = $image_thumb;
$cat = $_POST["cat_$x"];
$include = $_POST["include_$x"];
if ($include = ""){
break;
}
//debugging
//echo "$image_title - $image_thumb - $image_big - $image_super - $gallery - $active<br>";
$sql = "INSERT into photo_members_cpics (id, member, client, image_title, image_small, image_big, protecting, password, price, price2, price3, print_size, print_size2, print_size3, framed_cost, category) VALUES ('', '$username', '$clientid', '$image_title', 'images/members/$username/$clientid/thumb/$image_thumb', 'images/members/$username/$clientid/thumb/$image_thumb', '$protecting', '$password', '$price', '$price2', '$price3', '$print_size', '$print_size2', '$print_size3', '$framed_cost', '$cat' )";
$rs = mysql_query($sql) or die (mysql_error());
++$x;
}
I took ut a few of the $_post gatherings cos you dint need to see them,
hope this helps someone else out, just copy and paste and it will make sense in dreamweaver
diegomh7