-2
我有刮图片的代码,网址是相对前:如何将相对网址修改为绝对网址?
/upload/produse/Blu-ray/BD-H6500.jpg?maxwidth=800&maxheight=800
和我的魔杖变成绝对URL例如:
example.com/upload/produse/Blu-ray/BD-H6500.jpg
这里是我的代码:
if(isset($this->request->post['image_scrapper'])){
$imageQuery = $xpath->query("//div[@id='fancybox-content']//img/@src");
if($imageQuery->length > 0){
foreach ($imageQuery as $key => $image){
$extensie = end((explode('/', $image->nodeValue)));
$extensie = end((explode('.', $extensie)));
$model = preg_replace("/[^a-zA-Z0-9 -\/]+/","",trim($this->request->post['model']));
$imageName = str_replace(" ","-",trim($this->request->post['product_description']['1']['name']));
$imageName = preg_replace("/[^a-zA-Z0-9 -]+/","",$imageName);
$imageName .= "-".preg_replace("/[^a-zA-Z0-9 -]+/","",$model);
$imageName = strtolower($imageName);
$imageName = preg_replace("/[-]+/","-",$imageName);
$imageName .= '-'.rand().'.'.$extensie;
$imageName = 'data/'.$imageName;
copy($image->nodeValue, DIR_IMAGE.$imageName);
if($key == '0'){
$this->model_catalog_product->firstImage($product_id, $imageName);
}else{
$this->model_catalog_product->aditionaleImage($product_id, $imageName);
}
}
}
}
在此先感谢您的帮助。
看看[phpUri(https://github.com/monkeysuffrage/phpuri) – pguardiario 2015-02-06 06:43:43