3
我的电流路径是=改变新目录wp_handle_upload
(本地主机/ WordPress的/可湿性粉剂内容/上传/ 2014/05/Koala81.jpg);
我设置此路径=
(本地主机/ WordPress的/可湿性粉剂内容/插件/ XD/product_image/Koala81.jpg); (!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();
}
}
漂亮的代码,但什么是问题/你想做什么? – Howli
文件上传路径已更改 – vijay