1

Code:

$filename = '12345.jpeg';
$source = imagecreatefromstring($imageData); 
$imageSave = imagejpeg($source,$filename,100); 
imagedestroy($source);
$this->ftp->connect();
$this->ftp->upload($imageSave,'/public_ftp/incoming/'.$filename,'ascii', 0775); 
$this->ftp->close();

Error: Codeigniter failed to open stream permission when upload images.

Whyme
  • 11
  • 1
  • 4

1 Answers1

1

Probably it is a permissions issue. Try this:

sudo chmod -R 777 path/to/public_ftp/incoming/

However, this will give permission to everyone. For localhost this is ok. But for production environment you should do it in another way. Check this answer for more info

@edit

If you are getting this error when trying to upload a file from a form. codeigniter documentation:

The Upload Folder

You'll need a destination folder for your uploaded images. Create a folder at the root of your CodeIgniter installation called uploads and set its file permissions to 777.

Do you have this folder with permissions set to 777?

Community
  • 1
  • 1
Gabriel Moretti
  • 676
  • 8
  • 23
  • Thank you. I set the premission 777 in GUI to incoming folder but the problem has not be solved. Why? – Whyme Jun 01 '15 at 10:48
  • You are getting the error when you are trying to upload this file to the ftp, or when you are trying to upload a file which are being received through a form? – Gabriel Moretti Jun 01 '15 at 10:53
  • First one. Thanks. I pass the base64 string to the php side. $imageData is a base64 string. You mean that I need to save the image in local host first? – Whyme Jun 01 '15 at 10:56
  • No.. I don't think that is the problem, since you are getting a **permissions** error. You could try it anyway. – Gabriel Moretti Jun 01 '15 at 11:03
  • The destination to FTP and CI are different. It will be the problem? – Whyme Jun 01 '15 at 11:09
  • What you mean by different destination? Did you checked if the permissions are really 777? How did you set this, via `$this->ftp->chmod()`? – Gabriel Moretti Jun 01 '15 at 11:13