Announcement

Collapse
No announcement yet.

saving a file on directory down with php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • saving a file on directory down with php

    Hi you guys....

    I want to save a file one directory down the actual script, how do I do this?
    I am using these lines...

    PHP Code:
    if (is_writable(content/$filename)) {
      if (
    $handle fopen($DOCUMENT_ROOT/content/$filename"w")) {
       
    fwrite($handle$escapedcontent);
       
    fclose($handle); 
    Thanks!

  • #2
    Let's say the script is located in /home/username/public_html/script/ - You can use ../$filename and it'll be in the directory below where the script is located, in this case /home/username/public_html/.

    Comment


    • #3
      That's up for me not down....

      Originally posted by Game Wizards
      Let's say the script is located in /home/username/public_html/script/ - You can use ../$filename and it'll be in the directory below where the script is located, in this case /home/username/public_html/.
      For me that's one directory up, not down but when I do content/$filename it says division by zero not possible....

      Comment


      • #4
        IS "content" a constant? (if it is, this doesnt apply)

        You need to surround it with "".

        Same with the /.

        Comment


        • #5
          Originally posted by merk
          IS "content" a constant? (if it is, this doesnt apply)

          You need to surround it with "".

          Same with the /.
          Well i fixed it like this $filename = "content/" . $filenamen;

          That's it.

          And yep it was a constant but this is the easiest way to fix it,
          @ least I think so after a few bears and a long night on the town...

          Comment


          • #6
            Originally posted by Duke of Lions
            Well i fixed it like this $filename = "content/" . $filenamen;

            That's it.

            And yep it was a constant but this is the easiest way to fix it,
            @ least I think so after a few bears and a long night on the town...
            so you defined "constant" in a define() function?

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X