/** * Upload Featured image via ajax * * @since 0.8 */ function featured_img_upload() { check_ajax_referer('auiu_featured_img', 'nonce'); $upload_data = array('name' => $_FILES['auiu_featured_img']['name'], 'type' => $_FILES['auiu_featured_img']['type'], 'tmp_name' => $_FILES['auiu_featured_img']['tmp_name'], 'error' => $_FILES['auiu_featured_img']['error'], 'size' => $_FILES['auiu_featured_img']['size']); $attach_id = auiu_upload_file($upload_data); if ($attach_id) { $html = auiu_feat_img_html($attach_id); $response = array('success' => true, 'html' => $html); echo json_encode($response); exit; } $response = array('success' => false); echo json_encode($response); exit; }
function upload_file() { check_ajax_referer('auiu_audio_track', 'nonce'); $upload = array('name' => $_FILES['auiu_attachment_file']['name'], 'type' => $_FILES['auiu_attachment_file']['type'], 'tmp_name' => $_FILES['auiu_attachment_file']['tmp_name'], 'error' => $_FILES['auiu_attachment_file']['error'], 'size' => $_FILES['auiu_attachment_file']['size']); $attach_id = auiu_upload_file($upload); if ($attach_id) { $html = $this->attach_html($attach_id); $response = array('success' => true, 'html' => $html); echo json_encode($response); exit; } $response = array('success' => false); echo json_encode($response); exit; }
/** * Upload the files to the post as attachemnt * * @param <type> $post_id */ function auiu_upload_attachment($post_id) { if (!isset($_FILES['auiu_post_attachments'])) { return false; } $fields = (int) auiu_get_option('attachment_num', 'auiu_frontend_posting'); for ($i = 0; $i < $fields; $i++) { $file_name = basename($_FILES['auiu_post_attachments']['name'][$i]); if ($file_name) { if ($file_name) { $upload = array('name' => $_FILES['auiu_post_attachments']['name'][$i], 'type' => $_FILES['auiu_post_attachments']['type'][$i], 'tmp_name' => $_FILES['auiu_post_attachments']['tmp_name'][$i], 'error' => $_FILES['auiu_post_attachments']['error'][$i], 'size' => $_FILES['auiu_post_attachments']['size'][$i]); auiu_upload_file($upload); } //file exists } // end for } }