當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileUtils::GetPath方法代碼示例

本文整理匯總了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;
 }
開發者ID:ChenXL581X,項目名稱:distributedcourse,代碼行數:10,代碼來源:TaskOperation.php

示例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;
        }
開發者ID:ChenXL581X,項目名稱:distributedcourse,代碼行數:31,代碼來源:insertTask_run.php

示例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;
開發者ID:ChenXL581X,項目名稱:distributedcourse,代碼行數:31,代碼來源:upfile.php

示例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);
開發者ID:ChenXL581X,項目名稱:distributedcourse,代碼行數:23,代碼來源:createfile_run.php


注:本文中的FileUtils::GetPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。