Phalcon--http Request

Source: Internet
Author: User

(generally used in the Controller method)

Get Value:

(1) Get the value directly:

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

(2) automatically add filter:

$email = $this->request->getpost ("User_email", "email");

(3) Manually add the filter:

$filter = new filter ();

$email = $filter->sanitize ($this->request->getpost ("User_email"), "email");

(4) If the value is NULL, set the default value

$email = $this->request->getpost ("User_email", "email", "[email protected]");

Using the request header information:

(1) Get the server IP Address:

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

(2) Obtain the client IP Address:

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

File Upload:

Use Phalcon\mvc\controller;

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 (), "\ n";

Move the file into the application

$file->moveto (' files/'. $file->getname ());

}

}

}

}

Phalcon--http Request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.