(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