Skip to content

Commit

Permalink
Add multi-file upload to bug reporting page
Browse files Browse the repository at this point in the history
Fixes #5228
  • Loading branch information
dregad authored and rombert committed Mar 25, 2012
1 parent 5006a3b commit 2648708
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
14 changes: 11 additions & 3 deletions bug_report.php
Expand Up @@ -85,7 +85,7 @@
$t_bug_data->due_date = date_get_null();
}

$f_file = gpc_get_file( 'file', null ); /** @todo (thraxisp) Note that this always returns a structure */
$f_files = gpc_get_file( 'ufile', null ); /** @todo (thraxisp) Note that this always returns a structure */
$f_report_stay = gpc_get_bool( 'report_stay', false );
$f_copy_notes_from_parent = gpc_get_bool( 'copy_notes_from_parent', false);
$f_copy_attachments_from_parent = gpc_get_bool( 'copy_attachments_from_parent', false);
Expand Down Expand Up @@ -142,8 +142,16 @@
last_visited_issue( $t_bug_id );

# Handle the file upload
if ( !is_blank( $f_file['tmp_name'] ) && ( 0 < $f_file['size'] ) ) {
file_add( $t_bug_id, $f_file, 'bug' );
for( $i = 0; $i < count( $f_files ); $i++ ) {
if( !empty( $f_files['name'][$i] ) ) {
$t_file['name'] = $f_files['name'][$i];
$t_file['tmp_name'] = $f_files['tmp_name'][$i];
$t_file['type'] = $f_files['type'][$i];
$t_file['error'] = $f_files['error'][$i];
$t_file['size'] = $f_files['size'][$i];

file_add( $t_bug_id, $t_file, 'bug' );
}
}

# Handle custom field submission
Expand Down
24 changes: 19 additions & 5 deletions bug_report_page.php
Expand Up @@ -479,8 +479,11 @@
}
} # foreach( $t_related_custom_field_ids as $t_id )
?>
<?php if ( $tpl_show_attachments ) { // File Upload (if enabled)
$t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
<?php
// File Upload (if enabled)
if ( $tpl_show_attachments ) {
$t_max_file_size = (int)min( ini_get_number( 'upload_max_filesize' ), ini_get_number( 'post_max_size' ), config_get( 'max_file_size' ) );
$t_file_upload_max_num = max( 1, config_get( 'file_upload_max_num' ) );
?>
<tr <?php echo helper_alternate_class() ?>>
<td class="category">
Expand All @@ -489,12 +492,23 @@
</td>
<td>
<input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" />
<input <?php echo helper_get_tab_index() ?> name="file" type="file" size="60" />
</td>
</tr>
<?php
// Display multiple file upload fields
for( $i = 0; $i < $t_file_upload_max_num; $i++ ) {
?>
<input id="ufile[]" name="ufile[]" type="file" size="50" />
<?php
if( $t_file_upload_max_num > 1 ) {
echo '<br />';
}
}
}
?>
</td>
</tr>


<?php
if ( $tpl_show_view_state ) {
?>
<tr <?php echo helper_alternate_class() ?>>
Expand Down

0 comments on commit 2648708

Please sign in to comment.