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)
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&nbsp;File" />
53 </form>
54 </div>
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470
function a
Definition: browser.js:14
type
Definition: menu-new.php:35
exit
$max_file_size
$host
$target_path
$template name