本文整理汇总了PHP中FileUtils::GetPath方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils::GetPath方法的具体用法?PHP FileUtils::GetPath怎么用?PHP FileUtils::GetPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::GetPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upfile
public function upfile($file, $fields)
{
$rs = FileUtils::upfile($file, true);
if ($rs != false) {
$fields['name'] = $rs;
$fields['url'] = FileUtils::GetPath() . "/" . $fields['name'];
}
$this->insertFile($fields);
return $fields;
}
示例2: Validate
require_once 'core/init.php';
if (Input::exists('post')) {
if (Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array('title' => array('required' => true, 'name' => 'title'), 'type' => array('required' => true, 'name' => 'title'), 'endtime' => array('required' => true, 'name' => 'endtime'), 'desc' => array('required' => true, 'name' => 'desc')));
if ($validation->passed()) {
$teacher = new Teacher();
try {
$teacher->_taskOperation->taskCreate(array('title' => Input::get('title'), 'teacher_id' => $teacher->data()->id, 'type' => Input::get('type'), 'end_time' => strtotime(Input::get('endtime')), 'context' => Input::get('desc')));
$validate->check($_POST, array('uploadfile' => array('required' => true, 'name' => 'uploadfile')));
if ($validation->passed()) {
$arr = Input::get('uploadfile');
$taskID = $teacher->_taskOperation->getLastId();
foreach ($arr as $file) {
echo $file;
$teacher->_taskOperation->insertFile(array('name' => $file, 'teacher_id' => $teacher->data()->id, 'url' => FileUtils::GetPath() . "/" . $file, 'task_id' => $taskID));
}
}
Redirect::to('taskdetail.php?taskmark=' . $taskID);
// Redirect::to('course.php');
} catch (Exception $e) {
die($e->getMessage());
}
} else {
$errorInfo = '';
foreach ($validation->errors() as $error) {
//echo $error;
$errorInfo .= $error . '<br>';
}
echo $errorInfo;
}
示例3: Validate
$res["error"] = "";
//错误信息
$res["msg"] = "";
//提示信息
if (Input::exists('post')) {
if (1) {
$validate = new Validate();
$validation = $validate->check($_POST, array('taskId' => array('required' => true, 'name' => 'taskId')));
if ($validation->passed()) {
$teacher = new Teacher();
try {
$file = Input::getFile('file');
if ($file['error'] > 0) {
$res["error"] = "error";
} else {
$rs = $teacher->_taskOperation->upfile($file, array('name' => $file['name'], 'url' => FileUtils::GetPath() . "/" . $file['name'], 'task_id' => Input::get('taskId')));
Session::flash("taskdetail", "上传成功");
$res["msg"] = "ok";
}
} catch (Exception $e) {
Session::flash("taskdetail", "上传失败");
$res["error"] = "error:" . $e->getMessage();
}
} else {
$errorInfo = '';
foreach ($validation->errors() as $error) {
//echo $error;
$errorInfo .= $error . '<br>';
}
Session::flash("taskdetail", "上传失败");
$res["error"] = 'failed:' . $errorInfo;
示例4: Teacher
<?php
require_once 'core/init.php';
$res["error"] = "";
//错误信息
$res["msg"] = "";
//提示信息
$teacher = new Teacher();
try {
$file = Input::getFile('inputFile');
if ($file['error'] > 0) {
$res["error"] = "error";
} else {
$rs = FileUtils::upfile($file, true);
if ($rs != false) {
$res["msg"] = $rs;
$res["url"] = FileUtils::GetPath() . "/" . $file['name'];
}
}
} catch (Exception $e) {
$res["error"] = "error:" . $e->getMessage();
}
echo json_encode($res);