53 $this->value = $a_value;
73 $this->size = $a_size;
93 $this->filename = $a_val;
115 $this->suffixes = $a_suffixes;
125 return $this->suffixes;
137 $this->filename_selection =
true;
138 $this->filename_post = $a_post_var;
149 return $this->filename_selection ?
true :
false;
174 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
180 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
181 $suffix = $filename_arr[
"extension"];
182 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
183 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
184 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
193 case UPLOAD_ERR_INI_SIZE:
194 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
198 case UPLOAD_ERR_FORM_SIZE:
199 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
203 case UPLOAD_ERR_PARTIAL:
204 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
208 case UPLOAD_ERR_NO_FILE:
213 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
219 case UPLOAD_ERR_NO_TMP_DIR:
220 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
224 case UPLOAD_ERR_CANT_WRITE:
225 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
229 case UPLOAD_ERR_EXTENSION:
230 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
237 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
240 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
242 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
248 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
251 if ($vir[0] ==
false)
253 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
268 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
274 $f_tpl->setCurrentBlock(
'filename');
276 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
277 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
278 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
279 $f_tpl->parseCurrentBlock();
285 $f_tpl->setCurrentBlock(
'prop_file_propval');
286 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
287 $f_tpl->parseCurrentBlock();
291 if ($a_mode !=
"toolbar")
295 $f_tpl->setCurrentBlock(
"max_size");
296 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
298 $f_tpl->parseCurrentBlock();
301 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
302 $f_tpl->setVariable(
"ID", $this->
getFieldId());
303 $f_tpl->setVariable(
"SIZE", $this->
getSize());
305 return $f_tpl->get();
317 $a_tpl->setCurrentBlock(
"prop_generic");
318 $a_tpl->setVariable(
"PROP_GENERIC", $html);
319 $a_tpl->parseCurrentBlock();
329 $suff_str = $delim =
"";
332 $suff_str.= $delim.
".".$suffix;
335 $a_tpl->setCurrentBlock($a_block);
336 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
337 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
338 $a_tpl->parseCurrentBlock();
345 $umf = ini_get(
"upload_max_filesize");
347 $pms = ini_get(
"post_max_size");
350 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
352 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
353 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
355 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
356 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
359 $max_filesize = min($umf, $pms);
361 if (!$max_filesize) $max_filesize=max($umf, $pms);
364 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
366 return $max_filesize;
374 $html = $this->
render(
"toolbar");