Flames Posted January 6, 2010 Share Posted January 6, 2010 My current code is the following (it is implemented with ajax so that's why its coded like that) function create() { if(isset($_POST['file'])) { $file = $_POST['file']; } if(file_exists($file)) { echo "File already exists, please edit the existing file or delete it and try and create this file again."; die(); } if ($fh = fopen ($file, "w")) { // line 108 fclose ($fh); echo "File created successfully"; die(); } echo "Could not create new file"; } I get the error Warning: fopen(...) [function.fopen]: failed to open stream: No such file or directory in ... on line 108 Could not create new file all folders are chmodded 0751 apart from one which I changed to 0777 but that still doesnt work Any help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/187429-creating-a-new-file-with-php/ Share on other sites More sharing options...
Adam Posted January 6, 2010 Share Posted January 6, 2010 Well as the error says 'no such file or directory'; double check the file name and path. Could you show an example of the file string you're passing in? I'm guessing (assuming the file is definitely there) you're using an absolute path, or it's something of that nature. Quote Link to comment https://forums.phpfreaks.com/topic/187429-creating-a-new-file-with-php/#findComment-989743 Share on other sites More sharing options...
Flames Posted January 6, 2010 Author Share Posted January 6, 2010 The file doesnt exist already, this function is meant to create a new file, I've looked on the internet and this seems to be the correct method. Quote Link to comment https://forums.phpfreaks.com/topic/187429-creating-a-new-file-with-php/#findComment-989744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.