本文整理汇总了PHP中FORM::upload_file方法的典型用法代码示例。如果您正苦于以下问题:PHP FORM::upload_file方法的具体用法?PHP FORM::upload_file怎么用?PHP FORM::upload_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FORM
的用法示例。
在下文中一共展示了FORM::upload_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_form
function check_form()
{
$this->DBG->enter_method();
#while (list($key, $val)=each($this->fieldlist)) {
foreach ($this->fieldlist as $val) {
$formval = init($val['name'], "r", false);
// wert holen aus "request"
$this->DBG->watch_var("!!Found " . $val['type'], $formval);
if (array_key_exists('optional', $val) && $val['optional'] == true) {
if (!($formval != "" || array_key_exists('minmax', $val))) {
$this->DBG->send_message("-optional field ignored");
continue;
}
$this->DBG->send_message("-optional field processed!");
}
switch ($val['type']) {
case "file":
$this->DBG->watch_var("-File uploaded/" . $formval . " ex?", file_exists("uploaded/" . $formval));
if (strlen($formval) > 1) {
if (!file_exists("uploaded/" . $formval)) {
$this->DBG->send_message("-file upload error [file1]");
$this->fielderrors[$val['name']] = "Fehler beim Hochladen?";
} else {
$this->DBG->send_message("-file already uploaded [file2]");
array_push($this->results, array($val['name'] => $formval));
}
continue;
} else {
$reti = FORM::upload_file($val['name'], "uploaded/");
if (substr($reti, 0, 5) == "ERROR") {
// error occured with uploaded file
$this->DBG->send_message("-error during file upload [file3]");
$this->fielderrors[$val['name']] = substr($reti, 6);
} else {
//echo $reti; // is filename
$this->DBG->send_message("-file successfully uploaded [file4]");
array_push($this->results, array($val['name'] => $reti));
}
}
break;
case "link":
if (eregi("^http\\:", $formval)) {
$this->fielderrors[$val['name']] = "Links bitte ohne Protokoll (http://) angeben.";
} else {
array_push($this->results, array($val['name'] => trim($formval)));
}
break;
case "date":
$this->DBG->watch_var("-input", $formval);
$r = $this->check_date($formval);
$this->DBG->watch_var("-output", $r);
if (!eregi("^[0-9]", $r)) {
$this->DBG->send_message("-invalid date!");
$this->fielderrors[$val['name']] = $r;
} else {
array_push($this->results, array($val['name'] => $r));
$_REQUEST[$val['name']] = $r;
}
break;
case "site_select":
$formval = init(substr($val['name'], 0, -2), "r");
// wert holen aus "request"
$this->DBG->watch_var("-SiteSelect:" . $val['name'], $formval);
// trivial
if (is_array($formval)) {
array_push($this->results, array($val['name'] => $formval));
break;
}
$this->fielderrors[$val['name']] = "Bitte wählen Sie mindestens einen Bereich aus!";
break;
case "source_select":
// trivial
$this->DBG->watch_var("-F:" . $val['name'], $formval);
if ($formval > 0) {
array_push($this->results, array($val['name'] => $formval));
break;
}
$this->fielderrors[$val['name']] = "Bitte wählen Sie eine Quelle aus oder erstellen eine neue!";
break;
default:
$this->DBG->watch_var("-Default, Type is", $val['type']);
case "text":
// trivial
$this->DBG->watch_var("-Text-Field", $val);
$this->DBG->watch_var("-OR-Field", $val['_or']);
/* Bedingungsliste */
// wert?
(bool) ($wert = strlen(trim($formval)) > 0);
$this->DBG->watch_var("wert", $wert);
// abhängigkeit
(bool) ($or = array_key_exists('_or', $val));
$this->DBG->watch_var("or", $or);
// abhängiges feld hat wert (hat keinen fehler)
(bool) ($or_wert = $or ? !array_key_exists($val['_or'], $this->fielderrors) : false);
$this->DBG->watch_var("or_wert", $or_wert);
// besteht eine min/max bedingung?
(bool) ($minmax = array_key_exists('minmax', $val) ? true : false);
// ist feld optional? (dann darf es leer sein, oder muss die min/max bedingung erfüllen)
(bool) ($optional = array_key_exists('optional', $val) && $val['optional'] == true ? true : false);
// wert vorhanden, schreiben!
//.........这里部分代码省略.........
示例2: check_form
function check_form()
{
$this->DBG->enter_method();
while (list($key, $val) = each($this->fieldlist)) {
switch ($val['type']) {
case "file":
$this->DBG->watch_var("a file", $val);
$reti = FORM::upload_file($val['name'], "uploaded/");
if (substr($reti, 0, 5) == "ERROR") {
// error occured with uploaded file
// msg is substr($reti,6)
echo "<br>An error occured with uploaded file: " . substr($reti, 6) . "<p><a href='javascript:history.back();'>zurück und korrigieren</a></p>";
} else {
echo $reti;
}
break;
case "":
break;
}
// switch
}
// while
echo $reti;
$this->DBG->leave_method($reti);
}