Menu

#27024 problem with writable

closed
nobody
None
2025-09-15
2025-09-04
medlexo
No

suppose I wanted to update simple download count. I don't want to use database as it is overkill. I try to use php update the txt file but it keep failed.
I make a folder called as "count" and make the permission 777 but it keeps return to 775, hence I'm not able to write any file, what I did wrong? :
https://sourceforge.net/p/forge/documentation/Project%20Web%20Filesystem%20Permissions/

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Simple File Counter</title>
    <style>
        body {
            font-family: sans-serif;
            margin: 20px;
            text-align: center;
        }
        .container {
            border: 1px solid #ccc;
            padding: 20px;
            border-radius: 5px;
            max-width: 500px;
            margin: 0 auto;
        }
        .success {
            color: green;
            background-color: #e6ffe6;
            border: 1px solid green;
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
        }
        .error {
            color: red;
            background-color: #ffe6e6;
            border: 1px solid red;
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>File Output Test</h1>
        <p>This script attempts to write the number '1' to a file named 'out.txt' inside the 'count' folder.</p>

        <?php
        $output_dir = '/home/groups/m/me/<project name>/count/';
        $output_file = $output_dir . 'out.txt';

        $message = '';
        $message_type = '';

        if (is_writable($output_dir)) {
            if (file_put_contents($output_file, '1') !== false) {
                $message = 'Success! A file named "out.txt" with the content "1" was successfully written to the "count" folder.';
                $message_type = 'success';
            } else {
                $message = 'Error: Could not write to the file "out.txt". Please check file permissions.';
                $message_type = 'error';
            }
        } else {
            $message = 'Error: The directory "count" is not writable. Please check the directory permissions and set them to 775.';
            $message_type = 'error';
        }

        if ($message): ?>
            <div class="<?php echo htmlspecialchars($message_type); ?>">
                <?php echo htmlspecialchars($message); ?>
            </div>
        <?php endif; ?>
    </div>
</body>
</html>

Discussion

  • SourceForge Support

    Hello,

    Thank you for reaching out.

    Unfortunately, dynamic content is no longer supported.

    There have been recent changes to SourceForge's Project Web hosting. As part of these updates, dynamic content such as PHP, htacess, and database access are no longer supported on Project Web hosting.

    Sincerely,
    SourceForge Support

     
  • SourceForge Support

    • status: open --> closed
     
  • SourceForge Support

    Hello,

    We have not heard from you and are now closing this ticket.
    If you need any help moving forward, please submit another ticket.
    Thank you.

    Sincerely,

    SourceForge Support

     

Log in to post a comment.