You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.9 KiB
94 lines
3.9 KiB
<div class="row">
|
|
<div class="col-12">
|
|
<div class="section-title">Aggiungi file</div>
|
|
</div>
|
|
<div class="col-12">
|
|
|
|
<div class="sheet-box p-4">
|
|
|
|
<?php
|
|
if($_POST['go']){
|
|
|
|
if($_FILES['files']){
|
|
$files = reArrayFiles($_FILES['files']);
|
|
foreach ($files as $index => $file) {
|
|
if(is_uploaded_file($file['tmp_name'])){
|
|
$filename = date("YmdHis")."-".preg_replace('/[^a-zA-Z0-9\-\._]/','_', $file['name']);
|
|
$filesize = ($file['size'] < 1000000) ? round($file['size'] / 1000)."k" : round($file['size'] / 1000000)."M";
|
|
$title = $_POST['titles'][$index];
|
|
|
|
move_uploaded_file($file['tmp_name'], "../docs/ftp/$filename");
|
|
$qf=mysqli_query($conn, "INSERT INTO ftp VALUES(null, '$title', '$filename', ".$_POST['municipality'].", NOW(), ".$_POST['year'].",'$filesize')");
|
|
}
|
|
}
|
|
}
|
|
|
|
echo '<div class="col-10 text-center mx-auto my-5">
|
|
<p><i class="fa fa-check-circle font-alert p-4"></i></p>
|
|
File aggiunto/i correttamente!
|
|
</div>';
|
|
|
|
|
|
}else{
|
|
?>
|
|
<form method="post" enctype="multipart/form-data">
|
|
<div class="row">
|
|
<div class="col-8">
|
|
<span class="font-12">Carica in</span>
|
|
<select name="municipality">
|
|
<option value="">- Seleziona un comune - </option>
|
|
|
|
<?php
|
|
$q = mysqli_query($conn, "SELECT * FROM comuni ORDER BY comune ASC");
|
|
$cnt=0;
|
|
while($r = mysqli_fetch_array($q)){
|
|
echo '<option value="'.$r['id'].'" '.($_POST['municipality'] == $r['id'] ? 'selected' : '').'>'.$r['comune'].'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
<div class="col-4">
|
|
<span class="font-12">Anno</span>
|
|
<select name="year">
|
|
<option value="">- Seleziona l'anno - </option>
|
|
|
|
<?php
|
|
for($i = 2020; $i <= date('Y'); $i++){
|
|
echo '<option value="'.$i.'" '.(date('Y') == $i ? 'selected' : '').'>'.$i.'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<span class="font-12">Files</span>
|
|
<div class="files-list">
|
|
<div class="list">
|
|
<div class="row master">
|
|
<div class="col-8">
|
|
<input type="text" name="titles[]" placeholder="Nome del file">
|
|
</div>
|
|
<div class="col-4">
|
|
<input type="file" name="files[]">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<button class="button button-small add-file"><i class="fa fa-plus"></i> aggiungi riga</button>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-12 text-right">
|
|
<button type="submit" name="go" value="1">Aggiungi file</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|