Jump to content

Creating file (fopen) does not work in module


kendo101

Recommended Posts

Hello,

I am creating a simple module that needs to create a file, I am testing with the following code:

 

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
echo("DONE! SHOULD HAVE MADE THE FILE NOW");
 
It just writes a line to a simple .txt file. Now if I put this in a php file in say: public_html/testing/testing.php, it works fine.
 
But when I run the snippet within the module I am creating I also get the response "DONE! SHOULD HAVE MADE THE FILE NOW" but no file is created and no error is thrown. I'm not sure how I should debug the problem.
 
Does anyone know of why its having trouble creating files and why it doesn't throw any errors? Debugging in TRUE.
Link to comment
Share on other sites

Hi Kerm,

Can you elaborate on that? When running this snippet outside of the module, it simply creates the txt file in the same location as the php file. I would expect this to happen within the module also since I do not specify the path, it should create it in the same location as the script creating the file.

 

Host has taken a look at file permissions and said it should work, I was not specific on what they should be checking however.

 

Wouldn't it throw an error if it had issue creating the file? Right now it says it did not run into any problems yet it did not do its job.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...