mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 03:31:10 +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/');
|
$upload = new UploadPhoto($outputImagePath, 'cdn/img/');
|
||||||
self::$vidpreview = $upload->getSrc();
|
self::$vidpreview = $upload->getSrc();
|
||||||
$upload = new UploadPhoto($mp4File, 'cdn/video/');
|
$upload = new UploadPhoto($mp4File, 'cdn/video/');
|
||||||
|
echo explode($mp4File, '.')[1];
|
||||||
self::$videourl = $upload->getSrc();
|
self::$videourl = $upload->getSrc();
|
||||||
|
$exif = Json::return(
|
||||||
|
array(
|
||||||
|
'type' => 'none',
|
||||||
|
)
|
||||||
|
);
|
||||||
} else if (explode($type, '/')[0] === 'image') {
|
} else if (explode($type, '/')[0] === 'image') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$exif = new EXIF($_FILES['image']['tmp_name']);
|
$exif = new EXIF($_FILES['image']['tmp_name']);
|
||||||
$exif = $exif->getData();
|
$exif = $exif->getData();
|
||||||
$upload = new UploadPhoto($_FILES['image'], 'cdn/img/');
|
$upload = new UploadPhoto($_FILES['image'], 'cdn/img/');
|
||||||
|
|
|
@ -24,9 +24,19 @@ class Upload
|
||||||
}
|
}
|
||||||
public function __construct($file, $location)
|
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;
|
$cstrong = True;
|
||||||
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . 'jpeg';
|
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . $fileext;
|
||||||
$folder = $location . $filecdn;
|
$folder = $location . $filecdn;
|
||||||
$s3 = new \Aws\S3\S3Client([
|
$s3 = new \Aws\S3\S3Client([
|
||||||
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
|
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
|
||||||
|
@ -41,12 +51,12 @@ class Upload
|
||||||
$s3->putObject([
|
$s3->putObject([
|
||||||
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
|
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
|
||||||
'Key' => $location.$filecdn,
|
'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->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn;
|
||||||
$this->size = self::human_filesize(filesize($file['tmp_name']));
|
$this->size = self::human_filesize(filesize($tmpname));
|
||||||
$this->name = $file['name'];
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,8 +104,16 @@ if ($photo->i('id') !== null) {
|
||||||
<div style="display:inline-block">
|
<div style="display:inline-block">
|
||||||
<div id="underphoto_frame">
|
<div id="underphoto_frame">
|
||||||
<div id="ph_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="Фотография">
|
<img onerror="errimg(); this.onerror = null;" class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
||||||
<?php
|
<?php
|
||||||
|
}
|
||||||
if ($photo->i('priority') === 1) { ?>
|
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>
|
<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) { ?>
|
<?php } else if ($photo->i('priority') === 2) { ?>
|
||||||
|
|
|
@ -807,7 +807,27 @@ $user = new User(Auth::userid());
|
||||||
</select> <a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
|
</select> <a href="https://creativecommons.org/licenses/?lang=ru" target="_blank" class="und sm">Информация о лицензиях</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
@ -815,6 +835,8 @@ $user = new User(Auth::userid());
|
||||||
<button id="submitbtn" href="#" class="progress-button" data-loading="Идёт загрузка..." data-finished="Обработка..." type="submit">Опубликовать</button>
|
<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>
|
<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 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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -851,6 +873,7 @@ $user = new User(Auth::userid());
|
||||||
data: formData,
|
data: formData,
|
||||||
|
|
||||||
xhr: function() {
|
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>');
|
//$("#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));
|
var percentComplete = parseInt(((evt.loaded / evt.total) * 100));
|
||||||
console.log(evt.total);
|
console.log(evt.total);
|
||||||
|
|
||||||
// Обновляем прогресс загрузки
|
|
||||||
|
|
||||||
|
var elem = document.getElementById("myBar");
|
||||||
|
elem.style.width = percentComplete + '%';
|
||||||
|
elem.innerHTML = percentComplete + '%';
|
||||||
|
|
||||||
scrollProgressBarWidth(percentComplete);
|
scrollProgressBarWidth(percentComplete);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -870,6 +898,7 @@ $user = new User(Auth::userid());
|
||||||
|
|
||||||
|
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
$('#prgb').html('');
|
||||||
try {
|
try {
|
||||||
var jsonData = JSON.parse(response);
|
var jsonData = JSON.parse(response);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -941,6 +970,7 @@ $user = new User(Auth::userid());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
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>');
|
$("#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('');
|
$("#prgtd").html('');
|
||||||
$("#prgrsg").html('');
|
$("#prgrsg").html('');
|
||||||
|
|
Loading…
Reference in a new issue