67 $this->value = $a_value;
87 $this->filename = $a_val;
109 $this->suffixes = $a_suffixes;
119 return $this->suffixes;
131 $this->filename_selection =
true;
132 $this->filename_post = $a_post_var;
143 return $this->filename_selection ?
true :
false;
168 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
174 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
175 $suffix = $filename_arr[
"extension"];
176 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
177 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
178 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
179 $error = $_FILES[$this->
getPostVar()][
"error"];
187 case UPLOAD_ERR_INI_SIZE:
188 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
192 case UPLOAD_ERR_FORM_SIZE:
193 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
197 case UPLOAD_ERR_PARTIAL:
198 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
202 case UPLOAD_ERR_NO_FILE:
207 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
213 case UPLOAD_ERR_NO_TMP_DIR:
214 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
218 case UPLOAD_ERR_CANT_WRITE:
219 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
223 case UPLOAD_ERR_EXTENSION:
224 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
231 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
234 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
236 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
242 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
245 if ($vir[0] ==
false)
247 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
265 $a_tpl->setCurrentBlock(
'filename');
267 $a_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
268 $a_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
269 $a_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
270 $a_tpl->parseCurrentBlock();
275 $a_tpl->setCurrentBlock(
"prop_file");
276 $a_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
277 $a_tpl->setVariable(
"ID", $this->
getFieldId());
278 $a_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
280 $a_tpl->parseCurrentBlock();
289 $suff_str = $delim =
"";
292 $suff_str.= $delim.
".".$suffix;
295 $a_tpl->setCurrentBlock($a_block);
296 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
297 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
298 $a_tpl->parseCurrentBlock();
305 $umf = ini_get(
"upload_max_filesize");
307 $pms = ini_get(
"post_max_size");
310 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
312 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
313 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
315 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
316 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
319 $max_filesize = min($umf, $pms);
321 if (!$max_filesize) $max_filesize=max($umf, $pms);
324 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
326 return $max_filesize;