0
我有一個項目,我想用笨來調整上傳的圖片,並保存到遠程服務器笨調整圖像並保存到遠程服務器
我可以成功做到以下(所有我的本地機器上):
- 獲得上傳的圖片
- 保存到一個文件夾中TMP
- 調整在tmp文件夾
- 將圖像保存到最終目的地文件夾。
但是,我想再向前看一步。我想從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();
http://stackoverflow.com/questions/13154787/image-resize-before-uploading-in-codeigniter-php/13155566#13155566檢查我的答案那裏,你可能需要閱讀它的意見。這就是你想要的。 –