forked from leftypol/leftypol
parent
bc7fa47aa2
commit
a1f64335f9
3 changed files with 55 additions and 16 deletions
44
post.php
44
post.php
|
@ -657,6 +657,28 @@ function handle_post(){
|
|||
|
||||
}
|
||||
|
||||
// Convert multiple upload format to array of files. This makes the following code
|
||||
// work the same whether we used the JS or HTML multiple file upload techniques.
|
||||
if (array_key_exists('file_multiple', $_FILES)) {
|
||||
$file_array = $_FILES['file_multiple'];
|
||||
$_FILES = [];
|
||||
// If more than 0 files were uploaded
|
||||
if (!empty($file_array['tmp_name'][0])) {
|
||||
$i = 0;
|
||||
$n = count($file_array['tmp_name']);
|
||||
while ($i < $n) {
|
||||
$_FILES[strval($i+1)] = array(
|
||||
'name' => $file_array['name'][$i],
|
||||
'tmp_name' => $file_array['tmp_name'][$i],
|
||||
'type' => $file_array['type'][$i],
|
||||
'error' => $file_array['error'][$i],
|
||||
'size' => $file_array['size'][$i]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$post['name'] = $_POST['name'] != '' ? $_POST['name'] : $config['anonymous'];
|
||||
$post['subject'] = $_POST['subject'];
|
||||
$post['email'] = str_replace(' ', '%20', htmlspecialchars($_POST['email']));
|
||||
|
@ -781,20 +803,14 @@ function handle_post(){
|
|||
$i = 0;
|
||||
foreach ($_FILES as $key => $file) {
|
||||
if ($file['size'] && $file['tmp_name']) {
|
||||
$file['filename'] = urldecode($file['name']);
|
||||
$file['extension'] = strtolower(mb_substr($file['filename'], mb_strrpos($file['filename'], '.') + 1));
|
||||
if (isset($config['filename_func']))
|
||||
$file['file_id'] = $config['filename_func']($file);
|
||||
else
|
||||
$file['file_id'] = time() . substr(microtime(), 2, 3);
|
||||
|
||||
if (sizeof($_FILES) > 1)
|
||||
$file['file_id'] .= "-$i";
|
||||
|
||||
$file['file'] = $board['dir'] . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension'];
|
||||
$file['thumb'] = $board['dir'] . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']);
|
||||
$post['files'][] = $file;
|
||||
$i++;
|
||||
if (!in_array($file['error'], array(UPLOAD_ERR_NO_FILE, UPLOAD_ERR_OK))) {
|
||||
error(sprintf3($config['error']['phpfileserror'], array(
|
||||
'index' => $i+1,
|
||||
'code' => $file['error']
|
||||
)));
|
||||
}
|
||||
$post['files'][] = process_filenames($file, $board['dir'], (sizeof($_FILES) > 1), $i);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue