public function upload() { $profiler = new Profiler(); $form = new Formation(); $form->input('hello')->label(YES); $form->upload('file', YES)->label(YES)->rules('required|size[200KB]|allow[jpg,png,gif]'); $form->submit('Upload'); if ($form->validate()) { echo Eight::debug($form->as_array()); } echo $form->render(); }
/** * Runs the CURL methods to communicate with paypal. * * @param string paypal API method to run * @param string any additional name-value-pair query string data to send to paypal * @return mixed */ protected function make_paypal_api_request($nvp_str) { $postdata = http_build_query($this->api_authroization_fields) . '&' . $nvp_str; parse_str(urldecode($postdata), $nvpstr); Eight::log('debug', 'Connecting to ' . $this->api_connection_fields['ENDPOINT']); $ch = curl_init($this->api_connection_fields['ENDPOINT']); // Set custom curl options curl_setopt_array($ch, $this->curl_config); // Setting the nvpreq as POST FIELD to curl curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); // Getting response from server $response = curl_exec($ch); if (curl_errno($ch)) { throw new Eight_User_Exception('CURL ERROR', Eight::debug(array('curl_error_no' => curl_errno($ch), 'curl_error_msg' => curl_error($ch)))); // Moving to error page to display curl errors $this->session->set_flash(array('curl_error_no' => curl_errno($ch), 'curl_error_msg' => curl_error($ch))); url::redirect($this->api_connection_fields['ERRORURL']); } else { curl_close($ch); } return $response; }
/** * Demonstrates how to use the form helper with the Validation libraryfor file uploads . */ function form() { // Anything submitted? if ($_POST) { // Merge the globals into our validation object. $post = Validation::factory(array_merge($_POST, $_FILES)); // Ensure upload helper is correctly configured, config/upload.php contains default entries. // Uploads can be required or optional, but should be valid $post->add_rules('imageup1', 'upload::required', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[1M]'); $post->add_rules('imageup2', 'upload::required', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[1M]'); // Alternative syntax for multiple file upload validation rules //$post->add_rules('imageup.*', 'upload::required', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[1M]'); if ($post->validate()) { // It worked! // Move (and rename) the files from php upload folder to configured application folder upload::save('imageup1'); upload::save('imageup2'); echo 'Validation successfull, check your upload folder!'; } else { // You got validation errors echo '<p>validation errors: ' . var_export($post->errors(), YES) . '</p>'; echo Eight::debug($post); } } // Display the form echo form::open('examples/form', array('enctype' => 'multipart/form-data')); echo form::label('imageup', 'Image Uploads') . ':<br/>'; // Use discrete upload fields // Alternative syntax for multiple file uploads // echo form::upload('imageup[]').'<br/>'; echo form::upload('imageup1') . '<br/>'; echo form::upload('imageup2') . '<br/>'; echo form::submit('upload', 'Upload!'); echo form::close(); }