示例#1
0
    }
    public function save()
    {
        $data = $this->cleaned_data();
        $image_path = $data['image']->move_to($this->path);
        // do something with the data like saving it to a database...
        return $image_path;
    }
}
// Init form
$form = new UploadForm('/tmp', Phorm::POST, true);
// If the form is bound and valid, move the file to a more permanent location
$saved = null;
$file_error = null;
$photo_path = null;
if (($valid = $form->is_valid()) && $form->is_bound()) {
    try {
        $photo_path = $form->save();
        $saved = true;
    } catch (Exception $e) {
        $file_error = $e->message;
    }
}
?>
<html>
	<body>
		<style>
			table { border: 1px solid #ccc; padding: 2px 4px; }
			th { vertical-align: top; text-align: right; }
			td { vertical-align: top; }
			thead th { text-align: center; font-size: 16pt; background-color: #ccc; }