远程图片保存服务器设置(远程图片保存服务器设置方法)
- 服务器
- 2022-12-20 04:11:17
- 22
本篇文章给大家谈谈远程图片保存服务器设置,以及远程图片保存服务器设置方法对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、DZ!要怎么样才可以把远程图片下载到本地服务器上
- 2、curl获取远程图片时,如何设置本地保存路径?
- 3、怎么将上传到dede程序的图片自动保存到远程服务器上?
- 4、齐博CMS:怎么才能把图片方便的保存到远程服务器
DZ!要怎么样才可以把远程图片下载到本地服务器上
使用代码。% function saveimg(url) dim filename filename = "mytest.jpg" set xmlhttp=server.createobject("Microsoft.XMLHTTP")'创建XMLHTTP对象 xmlhttp.open "get",url,false xmlhttp.send'发送 if xmlhttp.status200 then'失败 saveimg="" else img=xmlhttp.ResponseBody'接收数据 set objAdostream=server.createobject("ADODB.Stream")'创建adodb.stream对象 objAdostream.Open()'打开 objAdostream.type=1'二进制方式 objAdostream.Write(img)'写入数据 objAdostream.SaveToFile(server.mappath("./"savepathfilename))'保存到文件 objAdostream.SetEOS'文件结尾 set objAdostream=nothing'释放对象 saveimg=savepathfilename'返回值 end if set xmlhttp=nothing end function %
麻烦采纳,谢谢!
curl获取远程图片时,如何设置本地保存路径?
设置保存路径
define('IMAGE_DIR', 'c:\\xampp\\htdocs\\scraper\\image\\');
保存图片函数。
$imageUrl = 你要的图片的url
$imageType = 你要的图片保存的格式
saveImage($imageUrl, $imageType = 'IMAGETYPE_GIF') {
if (!file_exists(IMAGE_DIR)) {
mkdir(IMAGE_DIR, 0777, true);
}
if( $imageType === IMAGETYPE_JPEG ) {
$fileExt = 'jpg';
} elseif ( $imageType === IMAGETYPE_GIF ) {
$fileExt = 'gif';
} elseif ( $imageType === IMAGETYPE_PNG ) {
$fileExt = 'png';
}
$newImageName = md5($imageUrl). '.' . $fileExt;
$image = new Image();
$image-load($imageUrl);
$image-resizeToWidth(100);
$image-save( IMAGE_DIR . $newImageName, $imageType );
return $newImageName;
}
这是我的图片类,保存前可转换格式,图片大小。
?php
class Image {
private $_image;
private $_imageFormat;
public function load($imageFile) {
$imageInfo = getImageSize($imageFile);
$this-_imageFormat = $imageInfo[2];
if( $this-_imageFormat === IMAGETYPE_JPEG ) {
$this-_image = imagecreatefromjpeg($imageFile);
} elseif( $this-_imageFormat === IMAGETYPE_GIF ) {
$this-_image = imagecreatefromgif($imageFile);
} elseif( $this-_imageFormat === IMAGETYPE_PNG ) {
$this-_image = imagecreatefrompng($imageFile);
}
}
public function save($imageFile, $_imageFormat=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
if( $_imageFormat == IMAGETYPE_JPEG ) {
imagejpeg($this-_image,$imageFile,$compression);
} elseif ( $_imageFormat == IMAGETYPE_GIF ) {
imagegif($this-_image,$imageFile);
} elseif ( $_imageFormat == IMAGETYPE_PNG ) {
imagepng($this-_image,$imageFile);
}
if( $permissions != null) {
chmod($imageFile,$permissions);
}
}
public function getWidth() {
return imagesx($this-_image);
}
public function getHeight() {
return imagesy($this-_image);
}
public function resizeToHeight($height) {
$ratio = $height / $this-getHeight();
$width = $this-getWidth() * $ratio;
$this-resize($width,$height);
}
public function resizeToWidth($width) {
$ratio = $width / $this-getWidth();
$height = $this-getheight() * $ratio;
$this-resize($width,$height);
}
public function scale($scale) {
$width = $this-getWidth() * $scale/100;
$height = $this-getheight() * $scale/100;
$this-resize($width,$height);
}
private function resize($width, $height) {
$newImage = imagecreatetruecolor($width, $height);
imagecopyresampled($newImage, $this-_image, 0, 0, 0, 0, $width, $height, $this-getWidth(), $this-getHeight());
$this-_image = $newImage;
}
}
?
怎么将上传到dede程序的图片自动保存到远程服务器上?
1、后台设置里有启用多站点功能
2、然后进行相关设置,也就是说你在此网站后台发布附件会自动同步到其他服务器上
3、具体还没有使用过,不过织梦后台是有这个功能的,你找找看哈
多素材织梦模板
为您解答
望采纳
齐博CMS:怎么才能把图片方便的保存到远程服务器
可以这样子,先采集到本地,然后将图片用FTP上传到另外一个空间,设置好图片路径,在后台统一使用替换功能来更改所有的图片链接
关于远程图片保存服务器设置和远程图片保存服务器设置方法的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
本文由admin于2022-12-20发表在靑年PHP官网,如有疑问,请联系我们。
本文链接:http://www.qnphp.com/post/170656.html