【问题标题】:Codeigniter resize image and save to a remote serverCodeigniter 调整图像大小并保存到远程服务器
【发布时间】:2012-11-07 06:15:27
【问题描述】:

我有一个项目,我想使用 codeigniter 来调整上传的图片大小并保存到远程服务器

我可以成功执行以下操作(全部在我的本地机器上):

  1. 获取上传的图片
  2. 保存到 tmp 文件夹
  3. 调整 tmp 文件夹中的图片大小
  4. 保存到最终目标文件夹。

但是,我想更进一步。我想从 tmp 获取图像,调整大小并保存到远程服务器。这是我认为它不起作用的示例代码。

$config['image_library'] = 'gd2';
$config['source_image'] = '/tmp/sample.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 80;
$config['height'] = 60;
$config['new_image'] = 'ftp://xx.xx.xxx.xxx/tmp/sample.jpg';  // can i do this?
$config['thumb_marker']  = '';

$ftpconfig['hostname'] = 'xx.xx.xxx.xxx';
$ftpconfig['username'] = 'name';
$ftpconfig['password'] = 'password';
$ftpconfig['debug'] = TRUE;

$this->ftp->connect($ftpconfig);

// and can I call CI to resize it and save to a ftp server after connent ftp?
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();

$this->ftp->close();

【问题讨论】:

标签: codeigniter ftp image-resizing remote-server


【解决方案1】:

你需要上传文件,现在你没有使用FTP库文件的上传方法,保存在你的服务器后你必须上传

$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);

请查看 ftp 类的用户指南

【讨论】:

    猜你喜欢
    • 2011-11-16
    • 2018-01-07
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多