function add_hero_banner($upload) { // echo '<pre>'; print_r($upload); exit; $uploads = wp_upload_dir(); //Get path of upload dir of wordpress if (is_writable($uploads['path'])) { //Check if upload dir is writable if (!empty($upload['tmp_name'])) { //Check if uploaded image is not empty if ($upload['tmp_name']) { //Check if image has been uploaded in temp directory $file = handle_image_upload($upload); /*Call our custom function to ACTUALLY upload the image*/ } else { $file = 'tmp_failed'; } } else { $file = 'already_exists'; } } else { $file = 'not_writable'; } return $file; }
public function update_prize() { $id = $this->params['id']; if ($id === 0) { set_flash(array('error' => "Sorry no current prize for id: {$id}")); redirect(url_for($this->name, 'prizes')); } if (isset($_POST['prize']['title'])) { // djm: take care of image upload /// $newthumb = handle_image_upload('thumbnail', "prize_{$_POST['prize']['id']}_"); if ($newthumb) { $_POST['prize']['thumbnail'] = $newthumb; } ///////////////////////////////////// if (($result = $this->db->update($_POST['prize'])) == 1) { set_flash(array('notice' => 'Successfully updated prize.')); redirect(url_for('street_team', 'view_prize', $id)); } else { set_flash(array('error' => 'Could not update your prize! Please try again. ' . $result)); redirect(url_for('street_team', 'modify_prize', $id)); } } else { set_flash(array('error' => 'Form data not submitted properly, please try again.')); redirect(url_for('street_team', 'modify_prize', $id)); } }