• Hey issue is solved for upload multiple image from fron end
    function my_handle_attachment($file_handler,$post_id,$set_thu=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 ( is_wp_error( $attachment_id ) ) {
    // There was an error uploading the image.
    } else {
    // The image was uploaded successfully!
    return $attach_id;
    //update_post_meta($post_id,’gallery_imgadv’,$attach_id);
    }
    }
    $files = $_FILES[“files”];
    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 (“files” => $file);
    foreach ($_FILES as $file => $array) {
    //$newupload = my_handle_attachment($file,$pid);
    $at = my_handle_attachment($file,$pid);
    add_post_meta($pid,’gallery_imgadv’,$at);
    }
    }
    }
    Thanx

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Upload multiple image from frontend’ is closed to new replies.