• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP media_handle_upload函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中media_handle_upload函数的典型用法代码示例。如果您正苦于以下问题:PHP media_handle_upload函数的具体用法?PHP media_handle_upload怎么用?PHP media_handle_upload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了media_handle_upload函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: actionSaveImage

 public function actionSaveImage()
 {
     if (!empty($_POST['imageUrl'])) {
         $url = \parse_url($_POST['imageUrl']);
         if ($curlDescriptor = \curl_init($_POST['imageUrl'])) {
             \curl_setopt($curlDescriptor, CURLOPT_HEADER, 0);
             \curl_setopt($curlDescriptor, CURLOPT_RETURNTRANSFER, 1);
             \curl_setopt($curlDescriptor, CURLOPT_BINARYTRANSFER, 1);
             $rawImage = \curl_exec($curlDescriptor);
             \curl_close($curlDescriptor);
             if ($rawImage) {
                 include_once ABSPATH . 'wp-admin/includes/image.php';
                 include_once ABSPATH . 'wp-admin/includes/file.php';
                 include_once ABSPATH . 'wp-admin/includes/media.php';
                 $wpFileType = \wp_check_filetype(\basename($url['path']), null);
                 $tmpDir = \ini_get('upload_tmp_dir') ? \ini_get('upload_tmp_dir') : \sys_get_temp_dir();
                 $tempName = $tmpDir . '/' . \uniqid() . '.' . $wpFileType['ext'];
                 \file_put_contents($tempName, $rawImage);
                 $_FILES['async-upload'] = array('name' => \trim(\str_replace(' ', '', basename($tempName))), 'type' => $wpFileType['type'], 'tmp_name' => $tempName, 'error' => 0, 'size' => \filesize($tempName));
                 \media_handle_upload('async-upload', 0, array(), array('test_form' => false, 'action' => 'upload-attachment'));
                 \wp_send_json(array('status' => 'success'));
             }
         }
     }
     \wp_send_json(array('status' => 'error'));
 }
开发者ID:sharpfuryz,项目名称:zoommy_wordpress,代码行数:26,代码来源:Helper.php


示例2: process_async_upload

 public function process_async_upload()
 {
     header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     if (!current_user_can('upload_files')) {
         wp_die(__('You do not have permission to upload files.'));
     }
     check_admin_referer($this->nonce_name);
     try {
         $attachment_id = media_handle_upload('async-upload', 0, [], ['mimes' => ['mp3|m4a' => 'audio/mpeg'], 'action' => $this->action]);
         $this->exception_if_error($attachment_id);
         require_once WPPPT_PLUGIN_PATH . '/migrations/functions.php';
         $post_id = \WPPPT\create_new_post(get_post($attachment_id));
         $this->exception_if_error($post_id);
         $podcast_id = intval($_REQUEST['podcast_id']);
         if (!empty($podcast_id)) {
             p2p_create_connection('podcast_clip_to_podcast', array('from' => $post_id, 'to' => $podcast_id));
         }
         echo apply_filters('wpppt_async_upload', $attachment_id);
     } catch (\Exception $e) {
         echo '<div class="error-div error">
         <a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss') . '</a>
         <strong>' . sprintf(__('&#8220;%s&#8221; has failed to upload.'), esc_html($_FILES['async-upload']['name'])) . '</strong><br />' . esc_html($e->getMessage()) . '</div>';
         exit;
     }
 }
开发者ID:nathanielks,项目名称:wp-podcast-post-type,代码行数:25,代码来源:BulkUpload.php


示例3: wpp_upload_image

function wpp_upload_image()
{
    if (count($_FILES) === 1) {
        $filetype = $_FILES['image']['type'];
        $allowed = '/image\\/(?:jpeg|png)/';
        if (preg_match($allowed, $filetype)) {
            if (!function_exists('wp_generate_attachment_metadata')) {
                require_once ABSPATH . "wp-admin" . '/includes/image.php';
                require_once ABSPATH . "wp-admin" . '/includes/file.php';
                require_once ABSPATH . "wp-admin" . '/includes/media.php';
            }
            foreach ($_FILES as $file => $array) {
                if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
                    return "upload error : " . $_FILES[$file]['error'];
                }
                $attach_id = media_handle_upload($file, 0);
            }
            //check for errors
            if (is_wp_error($attach_id)) {
                echo 'false';
            } else {
                echo $attach_id;
            }
        } else {
            _e('Please only use jpeg or png images!', 'wpp');
        }
    } else {
        _e('Please select only ONE image!', 'wpp');
    }
    wp_die();
    //immediately end our ajax response
}
开发者ID:saowapan,项目名称:wp-promotions,代码行数:32,代码来源:functions.php


示例4: theme_options_validate_callback_function

/**
 * Faz a validação dos dados
 * 
 */
function theme_options_validate_callback_function($input)
{
    if (!empty($_FILES['logo']['name'])) {
        $allowed_file_types = array('jpg' => 'image/jpg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png');
        if (!in_array($_FILES['logo']['type'], $allowed_file_types)) {
            wp_die(__('Sorry, this file type is not permitted for security reasons.'));
        }
        /*
         * O antigo wp_handle_upload( $_FILES[$field], array( 'test_form' => false ) ); foi substituído
         */
        $upload = media_handle_upload('logo', 0);
        if ($upload) {
            $input['logo'] = $upload;
        }
    } else {
        if (isset($_POST['restore-default-image']) && $_POST['restore-default-image'] == 1) {
            unset($input['logo']);
        } else {
            $logo = get_theme_option('logo');
            if (!empty($logo)) {
                $input['logo'] = get_theme_option('logo');
            }
        }
    }
    return $input;
}
开发者ID:aspto,项目名称:wordpress-themes,代码行数:30,代码来源:theme-options.php


示例5: upload

 /**
  * Uploads file
  *
  * @param string Key to $_FILES
  * @return int Attachment ID
  *
  * @abstract
  */
 static function upload($file)
 {
     if (!isset($file)) {
         return;
     }
     $file = media_handle_upload($file, 0, array(), array('test_form' => false, 'mimes' => array('csv' => 'text/csv')));
     return $file;
 }
开发者ID:trendwerk,项目名称:csv-importer,代码行数:16,代码来源:class-tp-csv-queue.php


示例6: handle_file

 /**
  * Upload file and return relevant attachment info
  *
  * @param string $value
  * @param int $field_id
  * @since 6.4
  * @return array|int
  */
 public function handle_file($value, $field_id)
 {
     $slug = get_post_meta($field_id, 'ccf_field_slug', true);
     $file_id = media_handle_upload('ccf_field_' . $slug, 0);
     if (is_wp_error($file_id)) {
         return 0;
     }
     $url = wp_get_attachment_url($file_id);
     return array('id' => $file_id, 'url' => $url, 'file_name' => basename($url));
 }
开发者ID:karthikakamalanathan,项目名称:wp-cookieLawInfo,代码行数:18,代码来源:class-ccf-form-handler.php


示例7: wplf_ajax_submit_handler

function wplf_ajax_submit_handler()
{
    $return = new stdClass();
    $return->ok = 1;
    // allow user to pre-process the post fields
    do_action('wplf_pre_validate_submission');
    // validate form fields
    // @see: wplf-form-validation.php
    $return = apply_filters('wplf_validate_submission', $return);
    if ($return->ok) {
        // form existence has already been validated via filters
        $form = get_post(intval($_POST['_form_id']));
        // the title is the value of whatever the first field was in the form
        $title_format = get_post_meta($form->ID, '_wplf_title_format', true);
        // substitute the %..% tags with field values
        $post_title = $title_format;
        preg_match_all('/%(.+?)%/', $post_title, $toks);
        foreach ($toks[1] as $tok) {
            $replace = '';
            if (array_key_exists($tok, $_POST)) {
                $replace = sanitize_text_field($_POST[$tok]);
            }
            $post_title = preg_replace('/%.+?%/', $replace, $post_title, 1);
        }
        // create submission post
        $post_id = wp_insert_post(array('post_title' => $post_title, 'post_status' => 'publish', 'post_type' => 'wplf-submission'));
        // add submission data as meta values
        foreach ($_POST as $key => $value) {
            if (!is_array($value)) {
                add_post_meta($post_id, $key, esc_html($value), true);
            } else {
                add_post_meta($post_id, $key, esc_html(json_encode($value)), true);
            }
        }
        // handle files
        foreach ($_FILES as $key => $file) {
            // Is this enough security wise?
            // Currenly only supports 1 file per input
            $attach_id = media_handle_upload($key, 0, array(), array("test_form" => false));
            add_post_meta($post_id, $key, wp_get_attachment_url($attach_id));
            add_post_meta($post_id, $key . "_attachment", $attach_id);
        }
        $return->submission_id = $post_id;
        $return->submission_title = $post_title;
        $return->form_id = $form->ID;
        // return the success message for the form
        $return->success = apply_filters('the_content', get_post_meta($form->ID, '_wplf_thank_you', true));
        // allow user to attach custom actions after the submission has been received
        // these could be confirmation emails, additional processing for the submission fields, e.g.
        do_action('wplf_post_validate_submission', $return);
    }
    // respond with json
    wp_send_json($return);
    wp_die();
}
开发者ID:anttiviljami,项目名称:wp-libre-form,代码行数:55,代码来源:wplf-ajax.php


示例8: anno_popup_images_iframe_html

function anno_popup_images_iframe_html()
{
    $errors = array();
    if (isset($_POST['html-upload']) && !empty($_FILES)) {
        check_admin_referer('media-form');
        // Upload File button was clicked
        $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
        unset($_FILES);
        if (is_wp_error($id)) {
            $errors['upload_error'] = $id;
            $id = false;
        }
    }
    global $tab;
    $post_id = anno_get_post_id();
    $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $post_id, 'post_mime_type' => 'image', 'order' => 'ASC'));
    ?>
<body id="anno-popup-images">
<div id="anno-popup-images-inside" class="anno-mce-popup">
	<div class="anno-mce-popup-fields">
<?php 
    if (!empty($id)) {
        if (is_wp_error($id)) {
            echo '<div id="media-upload-error">' . esc_html($id->get_error_message()) . '</div>';
            exit;
        }
    }
    ?>
		<table class="anno-images">
			<thead>
				<tr>
					<th scope="col" class="img-list-img"></th>
					<th scope="col" class="img-list-title"></th>
					<th scope="col" class="img-list-actions"></th>
				</tr>
			</thead>
			<tbody id="media-items">
<?php 
    foreach ($attachments as $attachment_key => $attachment) {
        anno_popup_images_row_display($attachment);
        anno_popup_images_row_edit($attachment);
    }
    ?>
		
			</tbody>
		</table>

		<?php 
    anno_upload_form();
    ?>
	</div>
</body>
<?php 
}
开发者ID:nameofname,项目名称:momo-wordpress-theme,代码行数:54,代码来源:image-popup.php


示例9: mapasdevista_save_pins

/**
 * Create or update pins.
 */
function mapasdevista_save_pins()
{
    $error = array();
    if (isset($_POST['submit_pin']) && $_POST['submit_pin'] === 'new') {
        if (isset($_FILES['pin_file']) && $_FILES['pin_file']['size'] > 0) {
            include ABSPATH . 'wp-admin/includes/file.php';
            // para funcionar o
            include ABSPATH . 'wp-admin/includes/image.php';
            // media_handle_upload
            include ABSPATH . 'wp-admin/includes/media.php';
            //
            $r = media_handle_upload('pin_file', NULL);
            if (is_wp_error($r)) {
                function mapasdevista_save_pin_error_notice()
                {
                    echo '<div class="error"><p>' . __('Could not create directory.') . '</p></div>';
                }
                add_action('all_admin_notices', 'mapasdevista_save_pin_error_notice');
            } else {
                update_post_meta($r, '_pin_anchor', array('x' => 0, 'y' => 0));
                wp_redirect(add_query_arg(array('action' => 'edit', 'pin' => $r)));
            }
        }
    } elseif (isset($_POST['submit_pin']) && $_POST['submit_pin'] === 'edit') {
        if (isset($_GET['pin']) && is_numeric($_GET['pin'])) {
            $pin_id = intval(sprintf("%d", $_GET['pin']));
            if (isset($_POST['pin_anchor']) && preg_match('/^([0-9]+),([0-9]+)$/', $_POST['pin_anchor'], $coords)) {
                $anchor = array('x' => intval($coords[1]), 'y' => intval($coords[2]));
                update_post_meta($pin_id, '_pin_anchor', $anchor);
            }
            if (isset($_POST['pin_clickable']) && $_POST['pin_clickable'] === 'no') {
                update_post_meta($pin_id, '_pin_clickable', 'no');
            } else {
                delete_post_meta($pin_id, '_pin_clickable');
            }
            wp_redirect(add_query_arg(array('action' => 'edit', 'pin' => $pin_id)));
        }
    } else {
        if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['pin'])) {
            if (isset($_GET['pin']) && is_numeric($_GET['pin'])) {
                $pin_id = intval(sprintf("%d", $_GET['pin']));
                $pin = get_post($pin_id);
                if ($pin) {
                    remove_pin($pin_id);
                    wp_redirect(admin_url('admin.php?page=mapasdevista_pins_page&msg=pin-deleted'));
                    die;
                }
            }
            wp_redirect(admin_url('admin.php?page=mapasdevista_pins_page&msg=pin-does-not-exist'));
            die;
        }
    }
}
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:56,代码来源:pins.php


示例10: set_feautured_image

 public function set_feautured_image($data, $item_id)
 {
     if ($item_id) {
         require_once ABSPATH . 'wp-admin/includes/image.php';
         require_once ABSPATH . 'wp-admin/includes/file.php';
         require_once ABSPATH . 'wp-admin/includes/media.php';
         $this->attachment_id = media_handle_upload($data, $item_id);
         set_post_thumbnail($item_id, $this->attachment_id);
     } else {
         return false;
     }
 }
开发者ID:SYallin,项目名称:wpframe,代码行数:12,代码来源:AddPost.php


示例11: handle_file

 /**
  * Upload file and return relevant attachment info
  *
  * @param string $value
  * @param int $field_id
  * @since 6.4
  * @return array|int
  */
 public function handle_file($value, $field_id)
 {
     require_once trailingslashit(ABSPATH) . 'wp-admin/includes/file.php';
     require_once trailingslashit(ABSPATH) . 'wp-admin/includes/image.php';
     require_once trailingslashit(ABSPATH) . 'wp-admin/includes/media.php';
     $slug = get_post_meta($field_id, 'ccf_field_slug', true);
     $file_id = media_handle_upload('ccf_field_' . $slug, 0);
     if (is_wp_error($file_id)) {
         return 0;
     }
     $url = wp_get_attachment_url($file_id);
     return array('id' => $file_id, 'url' => $url, 'file_name' => basename($url));
 }
开发者ID:christianc1,项目名称:custom-contact-forms,代码行数:21,代码来源:class-ccf-form-handler.php


示例12: upload

 /**
  * <input type="file" name="my_image_upload" accept="image/jpeg,image/png,image/gif"/>
  * @return boolean/int
  */
 public function upload()
 {
     require_once ABSPATH . 'wp-admin/includes/image.php';
     require_once ABSPATH . 'wp-admin/includes/file.php';
     require_once ABSPATH . 'wp-admin/includes/media.php';
     // Позволим WordPress перехвалить загрузку.
     // не забываем указать атрибут name поля input - 'my_image_upload'
     $attachment_id = media_handle_upload('my_image_upload', 0);
     if (is_wp_error($attachment_id)) {
         return FALSE;
     } else {
         return $attachment_id;
     }
 }
开发者ID:kiselyou,项目名称:boilers,代码行数:18,代码来源:UploadFiles.php


示例13: uploadImage

 public function uploadImage($uploadname, $post_id = 0, $meta_key = false)
 {
     if (isset($_FILES[$uploadname]) && !empty($_FILES[$uploadname])) {
         require_once ABSPATH . 'wp-admin/includes/image.php';
         require_once ABSPATH . 'wp-admin/includes/file.php';
         require_once ABSPATH . 'wp-admin/includes/media.php';
         $attachment_id = media_handle_upload($uploadname, $post_id);
         if (is_wp_error($attachment_id)) {
             do_action('Error_throw', array($uploadname => $attachment_id->get_error_message()));
         } elseif ($post_id > 0) {
             self::setImage($post_id, $attachment_id, $meta_key);
         }
     }
 }
开发者ID:fregu,项目名称:orkanlia,代码行数:14,代码来源:images.php


示例14: attach

 public function attach()
 {
     $attachment_ids = array();
     $original_files = $_FILES;
     /*
      * Get file upload global settings
      */
     $multiple = get_option('rm_option_allow_multiple_file_uploads');
     /*
      * Handling multiple attachments
      */
     if ($multiple == "yes") {
         foreach ($_FILES as $f_name => $name) {
             // var_dump($f_name);
             $files = $_FILES[$f_name];
             foreach ($files['name'] as $key => $value) {
                 if ($files['name'][$key]) {
                     $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]);
                     $_FILES = array($f_name => $file);
                     foreach ($_FILES as $file => $array) {
                         $attach_id = $this->media_handle_attachment($file, 0);
                         if (is_wp_error($attach_id)) {
                             break;
                         } else {
                             $attachment_ids[$f_name][] = $attach_id;
                         }
                     }
                 }
                 $_FILES = $original_files;
             }
         }
     } else {
         /*
          * Handling single attachment
          */
         foreach ($_FILES as $key => $file) {
             require_once ABSPATH . "wp-admin" . '/includes/image.php';
             require_once ABSPATH . "wp-admin" . '/includes/file.php';
             require_once ABSPATH . "wp-admin" . '/includes/media.php';
             $attach_id = media_handle_upload($key, 0);
             if (is_wp_error($attach_id)) {
                 break;
             } else {
                 $attachment_ids[$key] = $attach_id;
             }
         }
     }
     return $attachment_ids;
 }
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:49,代码来源:class_rm_attachment_service.php


示例15: upload_file

 public function upload_file()
 {
     require_once ABSPATH . "wp-admin" . '/includes/image.php';
     require_once ABSPATH . "wp-admin" . '/includes/file.php';
     require_once ABSPATH . "wp-admin" . '/includes/media.php';
     if ($_FILES) {
         foreach ($_FILES as $file => $array) {
             if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
                 echo "upload error : " . $_FILES[$file]['error'];
                 die;
             }
             return media_handle_upload($file, 0);
         }
     }
 }
开发者ID:coollog,项目名称:theboola,代码行数:15,代码来源:anspress-user.php


示例16: kbs_attach_file_to_ticket

/**
 * Attach files to a ticket.
 *
 * @since	1.0
 * @param	arr	$attachment	$_FILES
 * @param	int	$ticket_id	The ticket ID
 * @return	int	The attachment ID.
 */
function kbs_attach_file_to_ticket($attachment, $ticket_id)
{
    if (!kbs_file_uploads_are_enabled()) {
        return false;
    }
    add_filter('upload_dir', 'kbs_set_upload_dir');
    if ($_FILES[$attachment]['error'] !== UPLOAD_ERR_OK) {
        return false;
    }
    require_once ABSPATH . 'wp-admin/includes/image.php';
    require_once ABSPATH . 'wp-admin/includes/file.php';
    require_once ABSPATH . 'wp-admin/includes/media.php';
    $attach_id = media_handle_upload($attachment, $ticket_id);
    return $attach_id;
}
开发者ID:KB-Support,项目名称:kb-support,代码行数:23,代码来源:files.php


示例17: insert_attachment

function insert_attachment($file_handler, $post_id, $setthumb = 'false')
{
    // check to make sure its a successful upload
    if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) {
        __return_false();
    }
    require_once ABSPATH . "wp-admin" . '/includes/image.php';
    require_once ABSPATH . "wp-admin" . '/includes/file.php';
    require_once ABSPATH . "wp-admin" . '/includes/media.php';
    $attach_id = media_handle_upload($file_handler, $post_id);
    if ($setthumb) {
        update_post_meta($post_id, '_thumbnail_id', $attach_id);
    }
    return $attach_id;
}
开发者ID:freshbrewedweb,项目名称:asgard,代码行数:15,代码来源:functions.php


示例18: callback

 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (!current_user_can('upload_files')) {
         return new WP_Error('unauthorized', 'User cannot upload media.', 403);
     }
     $input = $this->input(true);
     $has_media = isset($input['media']) && $input['media'] ? count($input['media']) : false;
     $has_media_urls = isset($input['media_urls']) && $input['media_urls'] ? count($input['media_urls']) : false;
     $media_ids = $files = $errors = array();
     if ($has_media) {
         $this->api->trap_wp_die('upload_error');
         foreach ($input['media'] as $index => $media_item) {
             $_FILES['.api.media.item.'] = $media_item;
             // check for WP_Error if we ever actually need $media_id
             $media_id = media_handle_upload('.api.media.item.', 0);
             if (is_wp_error($media_id)) {
                 if (1 === count($input['media']) && !$has_media_urls) {
                     unset($_FILES['.api.media.item.']);
                     return $media_id;
                 }
                 $errors[$index]['error'] = $media_id->get_error_code();
                 $errors[$index]['message'] = $media_id->get_error_message();
             } else {
                 $media_ids[$index] = $media_id;
             }
             $files[] = $media_item;
         }
         $this->api->trap_wp_die(null);
         unset($_FILES['.api.media.item.']);
     }
     if ($has_media_urls) {
         foreach ($input['media_urls'] as $url) {
             $id = $this->handle_media_sideload($url);
             if (!empty($id) && is_int($id)) {
                 $media_ids[] = $id;
             }
         }
     }
     $results = array();
     foreach ($media_ids as $media_id) {
         $results[] = $this->get_media_item($media_id);
     }
     return array('media' => $results, 'errors' => $errors);
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:48,代码来源:class.wpcom-json-api-upload-media-endpoint.php


示例19: zo_insert_image

 public function zo_insert_image($input, $post_id)
 {
     if ($input) {
         foreach ($input as $file => $array) {
             if ($input[$file]['error'] !== UPLOAD_ERR_OK) {
                 return "upload error.";
             }
             require_once ABSPATH . 'wp-admin/includes/image.php';
             require_once ABSPATH . 'wp-admin/includes/file.php';
             require_once ABSPATH . 'wp-admin/includes/media.php';
             $attach_id = media_handle_upload($file, $post_id);
             update_post_meta($post_id, '_thumbnail_id', $attach_id);
             return $attach_id;
         }
     }
 }
开发者ID:jesusone,项目名称:fptcity,代码行数:16,代码来源:webservice-class.php


示例20: upload_file

 /**
  * Upload a new file to an album (please check if a user has access, before calling this feature)
  *
  * @param $post_id
  * @param $file
  * @param $nr
  *
  * @return bool
  */
 public function upload_file($post_id, $file, $nr)
 {
     if (false === current_user_can('edit_post', $post_id)) {
         $this->error = __('You are not allowed to edit posts and upload photos.', 'apg');
         return false;
     }
     if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
         $this->error = __('There was an upload error. Is your uploads folder writable?', 'apg');
         return false;
     }
     $attachment_id = media_handle_upload($file, $post_id);
     if (is_wp_error($attachment_id)) {
         $this->error = $attachment_id->get_error_message();
         return false;
     }
     update_post_meta($post_id, '_apg_photos', $nr);
     return true;
 }
开发者ID:Code-Brothers,项目名称:Awesome-Photo-Gallery,代码行数:27,代码来源:class-uploader.php



注:本文中的media_handle_upload函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP membership_dir函数代码示例发布时间:2022-05-24
下一篇:
PHP media_filelist函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap