Server Side Read & Write File

Hi ,
During project development, I wanted to create a TXT file and add a log to this file. Thanks to Wappler’s expandable feature, it was quite good to prepare it in my own way and use it the way I want. Now I can create a file as I want and add the logs I want to it.
I thought that instead of writing the logs on your site to the database, you might want to write them in a txt file or a file with the extension you want.

Write To File
It is very simple to use, I am sure you will see how simple it is by examining a little bit.

Read File

You can download it here.
writeAndReadFileModules-PHP-v10.zip (1.7 KB)

15 Likes

Thanks very much @s.alpaslan. This is a really useful module - for writing/reading text files for various purposes (as well as log files). It’s one of those basic features which is surprisingly still not built into Wappler.

Was there a particular reason you’ve only included ‘a’ and ‘a+’ as options for the read/write mode? It’s easy enough to add them to the .hjson file.

(I’ve also learnt 3 three new words in Turkish, bringing my vocabulary to a total of 3 words - until I forget them)

2 Likes

With a and a+ modes, it will create the file if it does not exist and generate the file content. In other words, if they use a different mode according to the purpose, they will see a problem and think that the reason for this error is due to the module. That’s why I just added a and a+ . All mods can be added inside the hjson file.

{ 
        name: 'mode', 
        optionName: 'mode', 
        title: 'mode', 
        required: true, 
        type: 'droplist', 
        values: [
            {title: 'r', value: 'r' },
            {title: 'r+', value: 'r+' },
            {title: 'w', value: 'w' },
            {title: 'w+', value: 'w+' },
            {title: 'a', value: 'a' },
            {title: 'a+', value: 'a+' },
            {title: 'x', value: 'x' },
            {title: 'x+', value: 'x+' }
        ],
        defaultValue: ''
      },

I will continue to add hidden Turkish words in every module :sweat_smile:

2 Likes

Mashallah komsu!

2 Likes

If there is anything you want from Turkey, let me know ( I can sent ) , komşu:))

2 Likes

Halva and sun :slightly_smiling_face: (We can get halva here, but it’s not the same as the real thing. We also get sun here - sometimes.)

3 Likes

@s.alpaslan
As of Feb 25, 2022 is this extension working fine just as it is with Wappler 4.6.2 and with PHP 8* ?

In PHP I used my own function like this for creating csv files from a query to the mysql tables.

For others who use php this might be a useful page to construct your own read/write file extension.

hi @NewMedia ,
it seems it has php 8 support :blush:
image
https://www.php.net/manual/tr/function.fwrite.php

1 Like

Is there anything else out there for NodeJS…?

hi @TMR ,

I wrote this for my project requirement at that time, but of course it can be written in nodejs. ( I can’t give information about the duration. I’ve been working for a big project for a long time. :slight_smile: )

1 Like

I’m surprised nothing like this comes as default with Wappler as its such a commonly used module.

Here you go, @TMR. I needed to add read functionality for one of my NodeJS projects: NodeJS Extension to Create/Write/Append Files

2 Likes

Hey, @tbvgl thank you for doing that, its a big help :grinning:

1 Like

@s.alpaslan - GENIUS! This extension has just opened up a whole load of options. I’ve just used it to create a sitemap.xml file really easily.

Huge thanks.

2 Likes

@s.alpaslan thanks for creating this. I’ve just used it in conjunction with @sid API file upload extension and it works perfectly. Very much appreciated.

It would be great to see this capability integrated into Wappler.

5 Likes