Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
f78c404ae2 | |||
3f8b51c78a | |||
|
2fdf5e9275 | ||
|
fbc85cf13c | ||
|
56bde40f69 | ||
|
37efdc7c81 | ||
|
394a770a26 | ||
|
bf1182be54 | ||
|
152772e3ad | ||
|
24c9f12695 | ||
|
e7fb076f12 | ||
|
dc768566fc | ||
|
14b9ca6686 | ||
|
891565f76c | ||
|
125ee53fe2 |
13
LICENSE
Normal file
13
LICENSE
Normal file
@ -0,0 +1,13 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
@ -3,9 +3,15 @@
|
||||
// Title
|
||||
$title = "imgpaste by gideonstar";
|
||||
|
||||
// Displayed text
|
||||
// Dropzone text
|
||||
$text = "Click or drop image here...";
|
||||
|
||||
// Footer text
|
||||
$footer = '<a href="https://git.stefanritter.de/gideonstar/imgpaste.git">imgpaste</a> by gideonstar';
|
||||
|
||||
// Themes can be found in the themes directory
|
||||
$theme = "gideonstar";
|
||||
|
||||
// Writeable directory for images. Will be created if it does not exist.
|
||||
$datadir = "i";
|
||||
|
||||
|
@ -13,13 +13,14 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?php echo $title; ?></title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="themes/<?php echo $theme; ?>/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="dropzone" class="nodrop">
|
||||
<div id="dropzone" class="inactive">
|
||||
<p><?php echo $text; ?></p>
|
||||
</div>
|
||||
<div id="footer"><?php echo $footer; ?></div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
|
37
script.js
37
script.js
@ -1,29 +1,32 @@
|
||||
dropzone = document.getElementById('dropzone');
|
||||
|
||||
filetypes = ['image/png', 'image/jpeg', 'image/gif'];
|
||||
|
||||
dropzone.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.classList.remove('nodrop');
|
||||
this.classList.add('drop');
|
||||
dropzone_toggle("on");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('dragleave', function(e) {
|
||||
e.preventDefault();
|
||||
dropzone_toggle("off");
|
||||
});
|
||||
|
||||
this.classList.remove('drop');
|
||||
this.classList.add('nodrop');
|
||||
dropzone.addEventListener('mousedown', function(e) {
|
||||
dropzone_toggle("on");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('mouseup', function(e) {
|
||||
dropzone_toggle("off");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.click();
|
||||
|
||||
input.onchange = function(e) {
|
||||
file = e.target.files[0];
|
||||
if( file.type == 'image/png' || file.type == 'image/jpeg' ) {
|
||||
if(filetypes.includes(file.type)) {
|
||||
upload(e.target.files[0]);
|
||||
}
|
||||
}
|
||||
@ -31,16 +34,24 @@ dropzone.addEventListener('click', function(e) {
|
||||
|
||||
dropzone.addEventListener('drop', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.classList.remove('drop');
|
||||
this.classList.add('nodrop');
|
||||
dropzone_toggle("off");
|
||||
|
||||
file = e.dataTransfer.files[0];
|
||||
if( file.type == 'image/png' || file.type == 'image/jpeg' ) {
|
||||
if(filetypes.includes(file.type)) {
|
||||
upload(e.dataTransfer.files[0]);
|
||||
}
|
||||
});
|
||||
|
||||
function dropzone_toggle(state) {
|
||||
if(state == "on") {
|
||||
dropzone.classList.remove('inactive');
|
||||
dropzone.classList.add('active');
|
||||
} else if(state == "off") {
|
||||
dropzone.classList.remove('active');
|
||||
dropzone.classList.add('inactive');
|
||||
}
|
||||
}
|
||||
|
||||
function upload(file) {
|
||||
const data = new FormData();
|
||||
data.append('upload', file)
|
||||
|
@ -1,6 +1,5 @@
|
||||
:root {
|
||||
--round: 20px;
|
||||
--border: 100px;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
@ -20,28 +19,43 @@ body {
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#dropzone {
|
||||
width: calc(100vw - var(--border));
|
||||
height: calc(100vh - var(--border));
|
||||
border-radius: var(--round);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 90vw;
|
||||
height: 200px;
|
||||
max-width: 500px;
|
||||
margin-top: 50px;
|
||||
border-radius: var(--round);
|
||||
}
|
||||
|
||||
.nodrop {
|
||||
background-color: #f5f5f5;
|
||||
outline: 2px dashed #d5d5d5;
|
||||
}
|
||||
|
||||
.drop {
|
||||
.active {
|
||||
background-color: #ffb703;
|
||||
outline: 2px dashed #fb8500;
|
||||
transition: .3s ease;
|
||||
}
|
||||
|
||||
.inactive {
|
||||
background-color: #f5f5f5;
|
||||
outline: 2px dashed #d5d5d5;
|
||||
transition: .3s ease;
|
||||
}
|
||||
|
||||
#footer {
|
||||
margin-top: 10px;
|
||||
color: white;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ffb703;
|
||||
text-decoration: none;
|
||||
}
|
@ -10,10 +10,13 @@ if(!is_dir($datadir)) {
|
||||
mkdir($datadir);
|
||||
}
|
||||
|
||||
$extensions = ['jpg', 'jpeg', 'png', 'gif'];
|
||||
|
||||
if(isset($_FILES['upload'])) {
|
||||
$extension = pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION);
|
||||
$extension = strtolower($extension);
|
||||
|
||||
if($extension == 'jpg' || $extension == 'jpeg' || $extension == 'png') {
|
||||
if(in_array($extension, $extensions)) {
|
||||
$filename = generate_filename($length) . '.' . $extension;
|
||||
move_uploaded_file($_FILES['upload']['tmp_name'], $datadir . '/' . $filename);
|
||||
echo json_encode(['datadir' => $datadir, 'filename' => $filename]);
|
||||
|
Loading…
Reference in New Issue
Block a user