0

First, this is the first time i code both of web service and android (normally just android), so please bear with me.

I tried to upload an image to the mysql (phpmyadmin) through the Codeigniter-based webservice. The image column in mysql (phpmyadmin) is BLOB.

$data['image'] = str_replace('data:image/jpg;base64,', '', $data['image']);
$data['image'] = str_replace(' ', '+', $data['image']);
$decoded= base64_decode($data['image']);

Then save the decoded file (this is where the permission is denied) :

file_put_contents('C:\xampp\htdocs\project\images', $decoded);

The image file should be saved in the "temp" folder, which is in the same folder with the php file (controller folder). However, the file is never stored (but the other data like name, email is stored on the mysql).

The error i got :

<p>Message:  file_put_contents(C:\xampp\htdocs\project\images): failed to open stream: Permission denied</p>

Im kinda stuck now. Please kindly help me.

Thanks for your help

Blaze Tama
  • 10,828
  • 13
  • 69
  • 129
  • Please see this link: http://stackoverflow.com/questions/11511511/how-to-save-a-png-image-server-side-from-a-base64-data-string – jewelnguyen8 Oct 09 '14 at 03:56

1 Answers1

2

As per the error I think that the images directory must have the Read-Write Permission, so that images can be stored into it.

You can give 777 permission to the images folder. If you want to give then type the following code in the terminal

sudo chmod -R 777 path

Please take care you give permission to only images folder, and not the other folders

Jigar
  • 44
  • 4