// CodeIgniter example function do_upload() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('upload_form', $error); } else { $data = array('upload_data' => $this->upload->data()); $this->load->view('upload_success', $data); } }
// same in FuelPHP function do_upload() { // Custom configuration for this upload $config = array( 'path' => DOCROOT.DS.'uploads/', 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'), ); // process the uploaded files in $_FILES Upload::process($config); // if there are any valid files if (Upload::is_valid()) { // save them according to the config Upload::save(); // call a model method to update the database Model_Uploads::add(Upload::get_files()); } // and process any errors foreach (Upload::get_errors() as $file) { // $file is an array with all file information, // $file['errors'] contains an array of all error occurred // each array element is an an array containing 'error' and 'message' } }
It looks like you're new here. If you want to get involved, click one of these buttons!