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());

                }

            }

        }

    }

  • 相关阅读:
    k8s的基本概念与基本功能
    STM32F030看门狗
    STM32F030低功耗
    STM32开发脱坑记
    ubuntu下安装wine并运行source insight
    Linux下使用Eclipse搭建ARM开发环境
    linux下的find文件查找命令与grep文件内容查找命令(转)
    STM32F030 BootLoader与应用程序的跳转设置
    MCU开发之MDK-ARM总结
    IIC协议总结
  • 原文地址:https://www.cnblogs.com/wujuntian/p/4695433.html
Copyright © 2011-2022 走看看