Codeigniter failed to open stream permission when

2019-08-13 22:24发布

问题:

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.

回答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?