Technical References - [writefile]

[writefile] functions allows you to perform a wide variety of tasks, from copying a purchased eBook to a special folder for downloading, to placing an uploaded file on your server.

numero = 107
interpreted = N
texte = Creating a new file [writefile path]Text[/writefile] Writes any text to a new file. Text is written exactly as in the template; it is not interpreted by the browser first. In other words, tabs, returns and multiple spaces will be written as is. However, the text WILL be interpreted by WebDNA first, so you may use variables or any WebDNA code necessary to create your text. Use secure=t in the tag to write the file with 660, or rw-rw---- permissions; i.e. [writefile path&secure=t] If a file by the same name exists, [writefile] will overwrite it. [writefile] is also used to handle uploaded files, such as jpgs, pdf, or any other format.

[writefile] does not 'understand' databases. If you want to write a new record to the end of a database, use [append] instead.

Example:
[WriteFile SomeTextFile]Hello, my name is Grant. The time is [time]This is a second line[/WriteFile]
The text file "SomeTextFile" is created and opened, and the text: Hello, my name is Grant. The time is 13:43:01 This is a second line is written to the file. Notice that carriage returns inside the context are written to the file exactly as they appear. Also notice that any WebDNA [xxx] tags inside the context are substituted for their real values before being written to the file. You may specify a full or partial URL to the file, as in "/Some Folder/file.txt" or "LocalFolder/file.txt."

You can also generate static ordinary webpages or even dynamic ones if you add <!--HAS_WEBDNA_TAGS--> at the begining of your file. WebDNA can literally autogenerate new programs. See [raw] context.

See also [appendfile], [createfolder], [copyfile], [copyfolder], [movefile], [deletefile] and [deletefolder] Creating a new file
[writefile path]Text[/writefile]
Writes any text to a new file. Text is written exactly as in the template; it is not interpreted by the browser first. In other words, tabs, returns and multiple spaces will be written as is. However, the text WILL be interpreted by WebDNA first, so you may use variables or any WebDNA code necessary to create your text. Use secure=t in the tag to write the file with 660, or rw-rw---- permissions; i.e. [writefile path&secure=t]

If a file by the same name exists, [writefile] will overwrite it. [writefile] is also used to handle uploaded files, such as jpgs, pdf, or any other format.

[writefile] does not 'understand' databases. If you want to write a new record to the end of a database, use [append] instead.



Example:

[WriteFile SomeTextFile]Hello, my name is Grant. The time is [time]
This is a second line[/WriteFile]

The text file "SomeTextFile" is created and opened, and the text:

Hello, my name is Grant. The time is 13:43:01
This is a second line
is written to the file. Notice that carriage returns inside the context are written to the file exactly as they appear. Also notice that any WebDNA [xxx] tags inside the context are substituted for their real values before being written to the file. You may specify a full or partial URL to the file, as in "/Some Folder/file.txt" or "LocalFolder/file.txt."

You can also generate static ordinary webpages or even dynamic ones if you add <!--HAS_WEBDNA_TAGS--> at the begining of your file. WebDNA can literally autogenerate new programs. See [raw] context.



See also [appendfile], [createfolder], [copyfile], [copyfolder], [movefile], [deletefile] and [deletefolder] Terry Wilson

DOWNLOAD WEBDNA NOW!

Top Articles:

WebDNA Libraries

A list of available libraries for WebDNA...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

F.A.Q

A compilation of some user's questions...

WebDNA Modules

A list of the currently available modules...

Tips and Tricks

A list of user-submitted tips ...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

Related Readings:

[SQLdisconnect]

...

[waitforfile]

The server waits until the file appears on disk...

[random]

will display a random number...

[xslt]

The [xslt] Context allows the WebDNA programmer to 'apply' an XSL style sheet to an XML document and thus 'transform' the XML data into any format the programmer desires (usually HTML)...

[ddeconnect]

...

[shownext]

[shownext] is a special context used to create links (or more accurately...