Cannot write a file to AWS EC2 instance - PHP

前端 未结 1 1087
野性不改
野性不改 2021-01-29 04:48

I am trying to create and write a file to ec2 instance. I am getting the error below despite the folder that i am writing possessing all the permissions required.



        
相关标签:
1条回答
  • 2021-01-29 05:45

    As the error clearly say. System is failing to open the file which is not there.

    $handle = fopen("thumbnailFolder/testFile.txt", "r");
    

    Above code open files in read mode. if there is no files then throws an error.

    If you want to open file to write then use try below code, this tries to open file and sets pointer at the begining if file is not there then creates the file in given name. for read and write use w+ instead of w

    $handle = fopen("thumbnailFolder/testFile.txt", "w");
    

    There are different modes with respect files. you can check below link for further details.

    http://php.net/manual/en/function.fopen.php

    0 讨论(0)
提交回复
热议问题