コード例 #1
0
/**
 * Retrieve the maximum upload file size
 *
 * @param array   $column                description of column in given table
 * @param integer $biggest_max_file_size biggest max file size for uploading
 *
 * @return array an html snippet and $biggest_max_file_size
 */
function PMA_getMaxUploadSize($column, $biggest_max_file_size)
{
    // find maximum upload size, based on field type
    /**
     * @todo with functions this is not so easy, as you can basically
     * process any data with function like MD5
     */
    global $max_upload_size;
    $max_field_sizes = array('tinyblob' => '256', 'blob' => '65536', 'mediumblob' => '16777216', 'longblob' => '4294967296');
    $this_field_max_size = $max_upload_size;
    // from PHP max
    if ($this_field_max_size > $max_field_sizes[$column['pma_type']]) {
        $this_field_max_size = $max_field_sizes[$column['pma_type']];
    }
    $html_output = PMA\libraries\Util::getFormattedMaximumUploadSize($this_field_max_size) . "\n";
    // do not generate here the MAX_FILE_SIZE, because we should
    // put only one in the form to accommodate the biggest field
    if ($this_field_max_size > $biggest_max_file_size) {
        $biggest_max_file_size = $this_field_max_size;
    }
    return array($html_output, $biggest_max_file_size);
}
 /**
  * Test for PMA\libraries\Util::getFormattedMaximumUploadSize
  *
  * @param int    $size Size
  * @param string $unit Unit
  * @param string $res  Result
  *
  * @return void
  *
  * @dataProvider dataProvider
  */
 function testMaximumUploadSize($size, $unit, $res)
 {
     $this->assertEquals("(" . __('Max: ') . $res . $unit . ")", PMA\libraries\Util::getFormattedMaximumUploadSize($size));
 }