Jump to content

fopen help


techiefreak05

Recommended Posts

When people register on my webite, a folder is created in their name and i have them create and edit files .. kinda like freewebs.com .. but i cant figure out how to create files... heres what i have..

<?php
fopen($_SESSION[username] . "/" . $_POST[name], "w+");
?>

Why doesnt that work?
Link to comment
https://forums.phpfreaks.com/topic/31299-fopen-help/
Share on other sites

You need to use fopen() in conjunction with fwrite().

My advice would be to join the path first, not in the function, so like this:

[code]<?php
$file = $_SESSION['username'] . "/" . $_POST['name'];
if ($fh = fopen($file, "w"){
  fwrite($fh, "This is test text\n");
}
else {
  echo "Couldn't create file\n";
}
?>[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/31299-fopen-help/#findComment-144844
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.