Enable multiple files upload (passed all tests) #16

Closed
wants to merge 2 commits into
from
@@ -544,10 +544,18 @@ function pagination($page, $current) {
/** Get file contents from $_FILES
* @param string
* @param bool
+* @param int file-data key in $_FILES array for multiple files upload
* @return mixed int for error, string otherwise
*/
-function get_file($key, $decompress = false) {
- $file = $_FILES[$key];
+function get_file($key, $decompress = false, $fileIndex = false) {
+ if ( $fileIndex !== false AND is_array($_FILES[$key]['name']) ) {
+ foreach ($_FILES[$key] AS $dataName => $dataValue) {
+ $file[$dataName] = $_FILES[$key][$dataName][$fileIndex];
+ }
+ }
+ else {
+ $file = $_FILES[$key];
+ }
if (!$file || $file["error"]) {
return $file["error"];
}
View
@@ -25,8 +25,13 @@
: "compress.bzip2://adminer.sql.bz2"
)), "rb");
$query = ($fp ? fread($fp, 1e6) : false);
- } elseif ($_FILES && $_FILES["sql_file"]["error"] != UPLOAD_ERR_NO_FILE) {
- $query = get_file("sql_file", true);
+ } elseif ($_FILES AND $_FILES["sql_file"]['error'][0] != UPLOAD_ERR_NO_FILE) {
+ $query = "";
+ foreach ($_FILES["sql_file"]['error'] AS $fKey => $fErr) {
+ if ($fErr != UPLOAD_ERR_NO_FILE) {
+ $query .= get_file("sql_file", true, $fKey);
+ }
+ }
}
if (is_string($query)) { // get_file() returns error as number, fread() as false
if (function_exists('memory_get_usage')) {
@@ -176,7 +181,7 @@
textarea("query", $q, 20);
echo ($_POST ? "" : "<script type='text/javascript'>document.getElementsByTagName('textarea')[0].focus();</script>\n");
echo "<p>" . (ini_bool("file_uploads")
- ? lang('File upload') . ': <input type="file" name="sql_file"' . ($_FILES && $_FILES["sql_file"]["error"] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') . '> (&lt; ' . ini_get("upload_max_filesize") . 'B)' // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
+ ? lang('File upload') . ': <input type="file" multiple name="sql_file[]"' . ($_FILES && $_FILES["sql_file"]["error"] != 4 ? '' : ' onchange="this.form[\'only_errors\'].checked = true;"') . '> (&lt; ' . ini_get("upload_max_filesize") . 'B)' // ignore post_max_size because it is for all form fields together and bytes computing would be necessary
: lang('File uploads are disabled.')
);
View
@@ -1 +1 @@
-java -jar "C:\Program Files\Selenium\selenium-server.jar" -htmlSuite "*iexplore" http://localhost/adminer/ "%CD%\selenium.html" results.html
+java -jar "C:\Users/i/Soft/selenium-server.jar" -htmlSuite "*firefox" http://localhost/_GIT/adminer/ "%CD%\selenium.html" results.html
Oops, something went wrong.