0

I have a project that I wanna use codeigniter to resize the uploaded image and save to a remote server

I can successfully do the following(all on my local machine):

  1. get the uploaded images
  2. save to a tmp folder
  3. resize the image in the tmp folder
  4. save to the final destination folder.

However, I wanna make one more step further. I wanna get the image from tmp, resize it and save to a remote server. here is the sample code I assume it wont work.

$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();
umefarooq
  • 4,540
  • 1
  • 29
  • 38
eded
  • 3,778
  • 8
  • 28
  • 42
  • http://stackoverflow.com/questions/13154787/image-resize-before-uploading-in-codeigniter-php/13155566#13155566 Check my answer there, you may need to read through the comments on it too. That does what you want. – Rick Calder Nov 07 '12 at 12:08

1 Answers1

1

you need to upload file, right now you are not using upload method of FTP library file after saving on your server you have to upload

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

please check user guide for ftp class

umefarooq
  • 4,540
  • 1
  • 29
  • 38