ok, so this code works beautifully for uploading multiple files at the same time. Now I want to add a caption (from a text field sitting next to each upload field).
the layout:
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="formContent"><input name="caption[]" type="text" size="41"></td>
<td class="formContent"><input name="upload1" type="file" size="25"></td>
</tr>
<tr>
<td class="formContent"><input name="caption[]" type="text" size="41"></td>
<td class="formContent"><input name="upload2" type="file" size="25"></td>
</tr>
<tr>
<td class="formContent"><input name="caption[]" type="text" size="41"></td>
<td class="formContent"><input name="upload3" type="file" size="25"></td>
</tr>
<tr>
<td class="formContent"><input name="caption[]" type="text" size="41"></td>
<td class="formContent"><input name="upload4" type="file" size="25"></td>
</tr>
</table></td>
and the file processor:
$file_dir = "/home/httpd/vhosts/*****.tv/httpdocs/controlPanel/uploads";
$file_url = "http://*****.tv/controlPanel/uploads";
if ( isset ( $_FILES ) ) {
foreach( $_FILES as $file_name => $file_array ) {
if ( is_uploaded_file ( $file_array['tmp_name'] ) ) {
$time = time();
$safe_filename = $time."-".$file_array['name'];
$filename = $file_array['name'];
$safe_filename = str_replace( " ", "_", $safe_filename );
move_uploaded_file( $file_array['tmp_name'], $file_dir.'/'.$safe_filename )
or die ( "Couldn't Copy" );
$file_query = "INSERT INTO caseFiles ( caseid, caseFilename, caseSafeFilename )
VALUES( '$caseid', '$filename', '$safe_filename' )";
if( ! mysql_query( $file_query, $link ) ) {
die("Could not execute query: ".mysql_error());
}
}
}
}
Basically, I can't figure out how to insert the right caption with the right file upload. Thanks for any input!
jason