YaWK
24.1
Yet another WebKit
simple_upload.php
Go to the documentation of this file.
1
<?php
2
/** @var $db \YAWK\db */
3
/*
4
if (!isset($simpleUpload))
5
{ // load gallery widget class
6
require_once 'classes/simpleUpload.php';
7
// create new gallery widget object
8
$simpleUpload = new \YAWK\WIDGETS\SIMPLEUPLOAD\UPLOAD\simpleUpload($db);
9
}
10
// init example widget
11
$simpleUpload->init();
12
exit;
13
*/
14
15
/* #######################
16
simple_upload.php
17
A SIMPLE UPLOAD WIDGET */
18
19
// init vars (widget defaults)
20
$target_path
=
"/var/www/YaWK-dev/media/uploads/"
;
21
$max_file_size
= 20000000;
// max filesize 20 MBytes (2000000 = 2 | 20000000 = 20 | 200000000 = 200)
22
$host
=
\YAWK\settings::getSetting
(
$db
,
"host"
);
23
24
if
(isset($_POST[
'upload'
]) && $_POST[
'upload'
] ===
"sent"
) {
25
// set full target path including filename
26
$target_path
=
$target_path
. basename( $_FILES[
'uploadedfile'
][
'name'
]);
27
28
if
(move_uploaded_file($_FILES[
'uploadedfile'
][
'tmp_name'
],
$target_path
)) {
29
echo
"The file "
. basename( $_FILES[
'uploadedfile'
][
'name'
]).
30
" has been uploaded: As you see..."
;
31
echo
"<img src=/YaWK-dev/media/uploads/"
;echo basename( $_FILES[
'uploadedfile'
][
'name'
]);echo
">"
;
32
echo
"<br><br><a href=\"$host\">back</a>"
;
33
exit
;
34
// if file could not be uploaded...
35
}
else
{
36
echo
"There was an error uploading the file, please try again!"
;
37
echo
"<br><br><a href=\"$host\">back</a>"
;
38
exit
;
39
40
}
41
// exit;
42
}
43
44
45
?>
46
<div>
47
<form enctype=
"multipart/form-data"
action=
"system/widgets/simple_upload/simple_upload.php"
method=
"POST"
>
48
<input
type
=
"hidden"
name
=
"MAX_FILE_SIZE"
value=
"<? print $max_file_size; ?>"
/>
49
<input
type
=
"hidden"
name
=
"upload"
value=
"sent"
/>
50
Choose
a
file to upload: <input
name
=
"uploadedfile"
type
=
"file"
/>
51
52
<input
type
=
"submit"
value=
"Upload File"
/>
53
</form>
54
</div>
YAWK\settings\getSetting
static getSetting($db, $property)
Get and return value for property from settings database.
Definition:
settings.php:470
$db
$db
Definition:
dismiss-notifications.php:4
a
function a
Definition:
browser.js:14
type
type
Definition:
menu-new.php:35
exit
exit
Definition:
message-fetch.php:17
$max_file_size
$max_file_size
Definition:
simple_upload.php:21
$host
$host
Definition:
simple_upload.php:22
$target_path
$target_path
Definition:
simple_upload.php:20
name
$template name
Definition:
template-assets.php:26
yawk.io
system
widgets
simple_upload
simple_upload.php
Generated on Tue Jan 16 2024 21:59:04 for YaWK by
doxygen 1.9.1