zoukankan      html  css  js  c++  java
  • phalcon——HTTP 请求

    (一般在控制器方法中使用)

    获取值:

    (1)直接获取值:

         $customerName = $this->request->getPost("name");

    2)自动添加过滤器:

         $email = $this->request->getPost("user_email", "email");

    3)手动添加过滤器:

         $filter = new Filter();

         $email  = $filter->sanitize($this->request->getPost("user_email"), "email");

    4)若值为空,设置默认值

         $email = $this->request->getPost("user_email", "email", "some@example.com");

    使用请求头信息:

    (1)获取服务器IP地址:

         $ipAddress  =  $this->request->getServerAddress();

    (2)获取客户端IP地址:

         $ipAddress  =  $this->request->getClientAddress();

    文件上传:

    use PhalconMvcController;

    class PostsController extends Controller

    {

        public function uploadAction()

        {

            // Check if the user has uploaded files

            if ($this->request->hasFiles()) {

                // Print the real file names and sizes

                foreach ($this->request->getUploadedFiles() as $file) {

                    // Print file details

                    echo $file->getName(), " ", $file->getSize(), " ";

                    // Move the file into the application

                    $file->moveTo('files/' . $file->getName());

                }

            }

        }

    }

  • 相关阅读:
    android 工具类 DateUtil
    POJ1580 水题,积累!
    POJ1159,Palindrome
    iOS开发UI篇章 15-项目中的常见文件
    MongoDB:Map-Reduce
    三层架构下实现用户登陆C#
    Inno Setup 安装inf文件的一个例子
    delphi 主线程向子线程发送消息
    PeekMessage和GetMessage函数的主要区别
    delphi SPCOMM的一些用法注意
  • 原文地址:https://www.cnblogs.com/wujuntian/p/4695433.html
Copyright © 2011-2022 走看看