Skip to main content

Posts

Showing posts from July, 2019

PHP Generate new pin

New PIN   generate function generatePIN($digits = 4){     $i = 0; //counter      while($i < $digits){         //generate a random number between 0 and 9.         $pin .= mt_rand(0, 9);         $i++;     }     return $pin; } //If I want a 4-digit PIN code. $pin = generatePIN(); 

API ( service ) Image or Video Upload

## SAVE  VIDEO public function uploadmedia() { $target_path = "assets/uploads/"; $target_path = $target_path . basename($_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $this->api_return( [ 'status' => true,    'result' => 'uploaded success' ], 200); } else{ $this->api_return( [ 'status' => false,    'result' => 'failed' ], 20); } } ## SAVE FILE IMAGE OR VIDEO public function savefile() { $filetype = $_FILES['file']['type']; if (strpos($filetype, 'image') !== false) { $type = 'image'; } if (strpos($filetype, 'video') !== false) { $type = 'video'; }         $filename = trim($_FILES['file']['name']); // $userid = trim($this->input->get('userid'));...