1 <?php
3 class TemplateWidget_file extends TemplateWidget
4 {
5 function render()
6 {
7 $title = set_post($this->description);
8 if(mb_strlen($this->value) == 0){
9 $ret = "<i>"._("No file uploaded yet")."</i>";
10 $ret.= "<br> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\">
11 <input id=\"{$this->postName}\"
12 name=\"{$this->postName}\"
13 type=\"file\"
14 size=\"20\"
15 maxlength=\"255\"
16 accept=\"*.*\"> ";
17 $ret.= "<button name='{$this->postName}_Upload'>"._("Upload")."</button>";
18 }else{
19 $ret = "<i>"._("File uploaded").": ".mb_strlen($this->value)." "._("Bytes");
20 $ret.= " <button name='{$this->postName}_Remove'>".msgPool::delButton()."</button>";
21 }
22 return($ret);
23 }
25 function save_object()
26 {
27 if(isset($_POST["{$this->postName}_Upload"]) && isset($_FILES[$this->postName]['tmp_name'])){
28 $this->value = file_get_contents($_FILES[$this->postName]['tmp_name']);
29 }
30 if(isset($_POST["{$this->postName}_Remove"])) $this->value ="";
31 }
32 }
34 ?>