$count = 5; // количество полей для загрузки файлов
$i = 0;
$path = './dir/'; // путь до папки куда сохранять, ./ считать от расположениея скрипта
if (!is_dir($path)) {
mkdir($path, 0777, true);
}
?>
<form action="?" enctype="multipart/form-data" method="post">
<?php while (++$i <= $count) : ?>
<div><input type="file" name="file[]"/></div>
<?php endwhile; ?>
<div><input type="submit" name="submit" value="submit"/></div>
</form>
<?php
if (isset($_POST['submit']) && count($_FILES)) {
for ($i = 0; $i <= $count; $i++) {
$newnames = [];
if (!empty($_FILES['file']['name'][$i])) {
if ($info = getimagesize($_FILES['file']['tmp_name'][$i])) {
$image = imagecreatefromstring(file_get_contents($_FILES['file']['tmp_name'][$i]));
$name = explode('.', $_FILES['file']['name'][$i]);
// обработка и сохранение
$newname = $path . time() . $name[0] . '.png'; // это имя для базы, даже путь полный, только имя можно получить например через basename();
$newnames[] = $newname; // basename($name);
imagepng($image, $newname, 9 , PNG_ALL_FILTERS);
} else {
echo '<h2>Какой то левый файл ' . $_FILES['file']['name'][$i] . '</h2>';
}
} else {
continue;
}
echo '<pre>' . print_r($newnames, true) . '</pre>';
}
} else {
echo '<h2>Ни чего не выбрано</h2>';
}
$dir = '/var/www/loc/files/';
$file_id = $_GET['file'] ?? null;
if (file_exists($file = $dir . $file_id) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
} else {
die('файла нет');
}
$file = 'file.csv';
$line = file($file);
$arr = [];
foreach ($line as $k => $v) {
$arr[] = explode(';', trim($v));
}
$days = ['пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'вс'];
$result = [];
foreach ($arr as $k => $value) {
if ($k > 1) {
$result[array_shift($value)] = array_combine($days, array_chunk($value, 24));
}
}
echo '<pre>' . print_r($result, true) . '</pre>';
echo date('Y-m-d H:i:s', $time + (365 * 24 * 3600));
class Test
{
private $array = [];
public function __construct(array $array)
{
$this->array = $array;
}
public function immutable(): self
{
return clone $this;
}
public function limit(int $limit, int $offset = 0): self
{
return new self(array_slice($this->array, $offset, $limit));
}
}
class Model extends BaseModel
{
private $id;
private $data;
private $other;
public function __construct()
{
foreach (unserialize($this->other as $key => $value) {
$this->{$key} = $value;
}
}