mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-22 16:41:04 +03:00
video upload
This commit is contained in:
parent
b55c757352
commit
e594ab732d
4 changed files with 65 additions and 12 deletions
|
@ -98,11 +98,16 @@ class Upload
|
|||
$upload = new UploadPhoto($outputImagePath, 'cdn/img/');
|
||||
self::$vidpreview = $upload->getSrc();
|
||||
$upload = new UploadPhoto($mp4File, 'cdn/video/');
|
||||
echo explode($mp4File, '.')[1];
|
||||
self::$videourl = $upload->getSrc();
|
||||
$exif = Json::return(
|
||||
array(
|
||||
'type' => 'none',
|
||||
)
|
||||
);
|
||||
} else if (explode($type, '/')[0] === 'image') {
|
||||
|
||||
|
||||
|
||||
$exif = new EXIF($_FILES['image']['tmp_name']);
|
||||
$exif = $exif->getData();
|
||||
$upload = new UploadPhoto($_FILES['image'], 'cdn/img/');
|
||||
|
|
|
@ -24,9 +24,19 @@ class Upload
|
|||
}
|
||||
public function __construct($file, $location)
|
||||
{
|
||||
|
||||
if (is_array($file)) {
|
||||
$tmpname = $file['tmp_name'];
|
||||
$type = explode('/', $file['type'])[0];
|
||||
$name = $file['name'];
|
||||
$fileext = pathinfo($file['name']);
|
||||
} else {
|
||||
$tmpname = $file;
|
||||
$type = filetype($file);
|
||||
$name = basename($file);
|
||||
$fileext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
}
|
||||
$cstrong = True;
|
||||
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . 'jpeg';
|
||||
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . $fileext;
|
||||
$folder = $location . $filecdn;
|
||||
$s3 = new \Aws\S3\S3Client([
|
||||
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
|
||||
|
@ -37,16 +47,16 @@ class Upload
|
|||
],
|
||||
'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'],
|
||||
]);
|
||||
|
||||
|
||||
$s3->putObject([
|
||||
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
|
||||
'Key' => $location.$filecdn,
|
||||
'SourceFile' => $file['tmp_name']
|
||||
'SourceFile' => $tmpname
|
||||
]);
|
||||
$this->type = explode('/', $file['type'])[0];
|
||||
$this->type = $type;
|
||||
$this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn;
|
||||
$this->size = self::human_filesize(filesize($file['tmp_name']));
|
||||
$this->name = $file['name'];
|
||||
$this->size = self::human_filesize(filesize($tmpname));
|
||||
$this->name = $name;
|
||||
}
|
||||
public function getType()
|
||||
{
|
||||
|
|
|
@ -104,8 +104,16 @@ if ($photo->i('id') !== null) {
|
|||
<div style="display:inline-block">
|
||||
<div id="underphoto_frame">
|
||||
<div id="ph_frame">
|
||||
<?php
|
||||
if ($photo->content('videourl') != null) { ?>
|
||||
<video controls>
|
||||
<source src="<?=$photo->content('videourl')?>">
|
||||
</video>
|
||||
|
||||
<?php } else { ?>
|
||||
<img onerror="errimg(); this.onerror = null;" class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
||||
<?php
|
||||
}
|
||||
if ($photo->i('priority') === 1) { ?>
|
||||
<div class="underphoto s17" style="cursor:help" title="Фотография не удовлетворяет действующим на момент публикации критериям качества снимков."><i style="position:relative; top:1px" class="fas fa-info-circle"></i> <b class="dot">Условная публикация</b></div>
|
||||
<?php } else if ($photo->i('priority') === 2) { ?>
|
||||
|
|
|
@ -807,14 +807,36 @@ $user = new User(Auth::userid());
|
|||
</select> <a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<style>
|
||||
.w3-green, .w3-hover-green:hover {
|
||||
color: #fff !important;
|
||||
background-color: #000 !important;
|
||||
}
|
||||
.w3-center {
|
||||
text-align: center !important;
|
||||
}
|
||||
.w3-container, .w3-panel {
|
||||
padding: 0.01em 16px;
|
||||
}
|
||||
.w3-light-grey, .w3-hover-light-grey:hover, .w3-light-gray, .w3-hover-light-gray:hover {
|
||||
color: #000 !important;
|
||||
background-color: #f1f1f1 !important;
|
||||
}
|
||||
.w3-container:after, .w3-container:before, .w3-panel:after, .w3-panel:before, .w3-row:after, .w3-row:before, .w3-row-padding:after, .w3-row-padding:before, .w3-cell-row:before, .w3-cell-row:after, .w3-clear:after, .w3-clear:before, .w3-bar:before, .w3-bar:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
</style>
|
||||
|
||||
<tr>
|
||||
<td></td>
|
||||
<td style="padding:20px 2px 12px">
|
||||
<button id="submitbtn" href="#" class="progress-button" data-loading="Идёт загрузка..." data-finished="Обработка..." type="submit">Опубликовать</button>
|
||||
<span id="statusbox" class="narrow" style="font-size:20px; font-weight:bold; position:relative; top:-12px"></span>
|
||||
<div id="errorsbox" style="display:none; color:red; margin-top:15px; font-weight:bold;"></div>
|
||||
<div style="margin-top: 20px; max-width: 50% !important;" id="prgb" class="w3-light-grey">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -849,8 +871,9 @@ $user = new User(Auth::userid());
|
|||
type: "POST",
|
||||
url: '/api/upload',
|
||||
data: formData,
|
||||
|
||||
|
||||
xhr: function() {
|
||||
$('#prgb').html('<div id="myBar" class="w3-container w3-green w3-center" style="width:0%">0%</div>');
|
||||
// Добавляем спиннер и блокируем кнопку во время загрузки
|
||||
//$("#r").html('<button type="submit" id="register" name="loginaccount" class="btn btn-block btn-primary py-2 ripple-handler mt-1 mb-3" disabled><div class="plus-button-reflection"></div>Опубликовать</button>');
|
||||
|
||||
|
@ -860,7 +883,12 @@ $user = new User(Auth::userid());
|
|||
var percentComplete = parseInt(((evt.loaded / evt.total) * 100));
|
||||
console.log(evt.total);
|
||||
|
||||
// Обновляем прогресс загрузки
|
||||
|
||||
|
||||
var elem = document.getElementById("myBar");
|
||||
elem.style.width = percentComplete + '%';
|
||||
elem.innerHTML = percentComplete + '%';
|
||||
|
||||
scrollProgressBarWidth(percentComplete);
|
||||
}
|
||||
}, false);
|
||||
|
@ -870,6 +898,7 @@ $user = new User(Auth::userid());
|
|||
|
||||
|
||||
success: function(response) {
|
||||
$('#prgb').html('');
|
||||
try {
|
||||
var jsonData = JSON.parse(response);
|
||||
} catch (err) {
|
||||
|
@ -941,6 +970,7 @@ $user = new User(Auth::userid());
|
|||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
$('#prgb').html('');
|
||||
$("#r").html('<button type="submit" id="register" name="loginaccount" class="btn btn-block btn-primary py-2 ripple-handler mt-1 mb-3">Опубликовать<span class="ripple-mask"><span class="ripple" style=""></span></span></button>');
|
||||
$("#prgtd").html('');
|
||||
$("#prgrsg").html('');
|
||||
|
|
Loading…
Reference in a new issue