my current path is =
(localhost/wordpress/wp-content/uploads/2014/05/Koala81.jpg) ;
I set this path =
(localhost/wordpress/wp-content/plugins/xd/product_image/Koala81.jpg) ;
if ( ! function_exists( ‘wp_handle_upload’ ) ) require_once( ABSPATH . ‘wp-admin/includes/file.php’ );
$uploadedfile = $_FILES['file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
$product_image = $movefile['url'];
$data = array(
'title' => $_POST['title'],
'description' => $_POST['description'],
'type' => $_POST['type'],
'vendor' => $_POST['vendor'],
'price' => $_POST['price'],
'comprice' => $_POST['comprice'],
'sku' => $_POST['sku'],
'barcode' => $_POST['barcode'],
'chargetaxes' => $_POST['chargetaxes'],
'shopadd' => $_POST['shopadd'],
'promulti' => $_POST['promulti'],
'product_status' => $_POST['product_status'],
'featured_image' => $_POST['featured_image'],
'file' => $product_image,
'tags' => $_POST['tags'],
'search' => $_POST['search'],
'meta' => $_POST['meta'],
'url' => $_POST['url'],
);
$success=$wpdb->insert( $table, $data);
$lastid = $wpdb->insert_id;
if($success == 1 && $_POST['featured_image'] == 'Yes')
{
$featured_image_product = $wpdb->query("UPDATE $table SET featured_image = 'No' where id != '$lastid'");
}
if($success){
echo "<h3 style='color:green;text-align:center;'>"."Products Added"."</h3>";
} else {
echo $wpdb->print_error();
}
}
The file upload path can’t be a URL so that you have to use the path like this “wp-content/plugins/xd/product_image/Koala81.jpg”