doudilin1225 2014-10-09 03:44
浏览 34

在Windows上的php Web服务中保存图像时权限被拒绝

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

  • 写回答

1条回答 默认 最新

  • dongmian8108 2014-10-11 08:43
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害