fopen Permission denied, Ubuntu, CodeIgniter

Lupita Noyra

I was trying fopen for my project. Which running on Ubuntu with CodeIgniter PHP framework. The result was like this:

A PHP Error was encountered
Severity: Warning
Message: fopen(testFile.txt): failed to open stream: Permission denied
Filename: controllers/home.php
Line Number: 10

can't open file

By the way, here are my code on Controller:

public function create_file(){
    $ourFileName = 'testFile.txt';
    $ourFileHandle = fopen($ourFileName, 'r') or die ("can't open file");
    fclose($ourFileHandle);
}

I looked at that code, and I thought that there is should be a path where I open the file, right? If yes, where should I put the path? Because, I followed this code from this tutorial: http://www.tizag.com/phpT/filecreate.php.

One thing that make me confuse is, there is no file testFile.txt and I wanna create it, but how to give the permission to create it. Because terminal will say No such file or directory for the file. What should I do?

I've also tried to run the chmod on www directory. But, it still didn't work. Hope anyone help me to handle this problem. Thank you...

Hari

There are 2 ways :

1.) chmod www directory to 777 by this command "sudo chmod -R 777 /var/www". This will give permissions recursively to all sub-folders and files.

2.) If you create any new folders (or projects in www directory) in future after the 1st step , then follow above :

=> Right click on your current project folder
=> Scroll to Properties
=> Scroll to permissions
=> Add permission for "Create and Delete files" for owner, group, others.
=> Now click on "Change permission for enclosed files"
=> Give appropriate permissions for files and folders there.

All done. Now fopen() should not give that warning.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Permission denied when opening a file on desktop with fopen

From Dev

PHP fopen Permission Denied - Windows Server remotely

From Dev

PHP - fopen: failed to open stream: Permission denied

From Dev

Ubuntu root permission denied

From Dev

Ubuntu:Permission denied error

From Dev

Permission denied Ubuntu Server

From Dev

Permission denied when deleting file created successfully by fopen

From Dev

PHP - fopen(): failed to open stream: Permission denied on a mac?

From Dev

SwiftMailer 'ErrorException' with message 'fopen(/tmp/...) failed to open stream: Permission denied'

From Dev

Docker 'WARNING: permission denied' on ubuntu

From Java

Ubuntu says "bash: ./program Permission denied"

From Dev

Permission Denied while Installing Docker Machine in Ubuntu

From Dev

Ubuntu: Write to serial port: permission denied

From Dev

Permission denied error for running command on ubuntu

From Dev

Ubuntu mate 16.04 matlab installation permission denied

From Dev

Permission Denied while Installing Docker Machine in Ubuntu

From Dev

Rsync failed: Permission denied (13) ubuntu

From Dev

Everything get [Permission Denied] Ubuntu Core

From Dev

Permission denied when starting .bashrc on ubuntu on windows

From Dev

Laravel S3 file upload : fopen(path to file) failed to open stream: Permission denied

From Dev

"permission denied" when converting ubuntu.iso to ubuntu.img

From Dev

Permission Denied

From Dev

ubuntu user& ssh login permission denied messages

From Dev

\copy permission denied while importing CSV to Postgres on Ubuntu

From Dev

Eclipse throwing Permission denied Exception in Ubuntu 12.04 LTS

From Dev

Ubuntu server ssh after reboot: Permission denied (publickey)

From Dev

403 - Permission denied error on Ubuntu 14.04 - apache2

From Dev

permission denied while executing START-DFS.SH in Ubuntu

From Dev

Permission denied when starting MySQL Server from MySQL Workbench in Ubuntu

Related Related

  1. 1

    Permission denied when opening a file on desktop with fopen

  2. 2

    PHP fopen Permission Denied - Windows Server remotely

  3. 3

    PHP - fopen: failed to open stream: Permission denied

  4. 4

    Ubuntu root permission denied

  5. 5

    Ubuntu:Permission denied error

  6. 6

    Permission denied Ubuntu Server

  7. 7

    Permission denied when deleting file created successfully by fopen

  8. 8

    PHP - fopen(): failed to open stream: Permission denied on a mac?

  9. 9

    SwiftMailer 'ErrorException' with message 'fopen(/tmp/...) failed to open stream: Permission denied'

  10. 10

    Docker 'WARNING: permission denied' on ubuntu

  11. 11

    Ubuntu says "bash: ./program Permission denied"

  12. 12

    Permission Denied while Installing Docker Machine in Ubuntu

  13. 13

    Ubuntu: Write to serial port: permission denied

  14. 14

    Permission denied error for running command on ubuntu

  15. 15

    Ubuntu mate 16.04 matlab installation permission denied

  16. 16

    Permission Denied while Installing Docker Machine in Ubuntu

  17. 17

    Rsync failed: Permission denied (13) ubuntu

  18. 18

    Everything get [Permission Denied] Ubuntu Core

  19. 19

    Permission denied when starting .bashrc on ubuntu on windows

  20. 20

    Laravel S3 file upload : fopen(path to file) failed to open stream: Permission denied

  21. 21

    "permission denied" when converting ubuntu.iso to ubuntu.img

  22. 22

    Permission Denied

  23. 23

    ubuntu user& ssh login permission denied messages

  24. 24

    \copy permission denied while importing CSV to Postgres on Ubuntu

  25. 25

    Eclipse throwing Permission denied Exception in Ubuntu 12.04 LTS

  26. 26

    Ubuntu server ssh after reboot: Permission denied (publickey)

  27. 27

    403 - Permission denied error on Ubuntu 14.04 - apache2

  28. 28

    permission denied while executing START-DFS.SH in Ubuntu

  29. 29

    Permission denied when starting MySQL Server from MySQL Workbench in Ubuntu

HotTag

Archive