Image

Imagedevolve_absolve wrote in Imagephp

This is starting to get to the point where I'm going to give up on files for my site. I want to keep it all nice and simple in terms of URLS and editing information. With a collection of articles involved, I can't afford to use MySQL for anything other than a pointer system.

So basic idea is that from the admin pages, you upload the files, based on subject, and it is all sorted, formatted, and indexed where necessary. This obviously isnt working as intended. I have tried to hunt on Google for any information which could be helpful, and checked the manuals where I can (too much jargon, head go boom). I'm at a dead end. It won't create a new file using the example in the PHP manual (as per the fwrite() page). It will only write if the file already exists. If the file is not there, it will create it on my PC, and since hunting has turned up no answers, I'm forced to throw myself at the mercy of the public. If there's something major I have missed, I would be grateful for any help




<?php
       
$filename = 'test/file1.txt';
$somecontent = "Add this to the file\n";

if (is_writable($filename)) {

    if (!$handle = fopen($filename, 'w')) {
        echo "Cannot open file ($filename)";
        exit;
    }

    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }
   
    echo "Success, wrote ($somecontent) to file ($filename)";
   
    fclose($handle);
                   
} else {
    echo "The file $filename is not writable";
}
?>