Designed by Derf !
3 en ligne  


 Search


Acheter - Vendre
neuf et occasion

pda, jeux vidéo, graveur, cd vierges, dvd vierges, matériel informatique, pc, ordinateur portable, logiciel, antivirus, annonces gratuites





   

Edit in a file

Create and modify a file





artvoila
It is better and clever to edit in a file instead of a database in numerous cases… It is even smoother and quite often faster! We can edit not only in a txt file but also in a php, asp, or html file, and that is very interesting!!! to create new web pages right on demand that will be addressed directly!

How to do it?


With ASP, you must get a folder that is not protected for editing (ask the ISP administrator to open it)

After that,

create an object such as Scripting.FileSystemObject
<% Set FSO = _
   Server.CreateObject("Scripting.FileSystemObject") %>


Collect the long path of the folder
that contains the file
<% dir = Server.MapPath("my_folder/") %>

Wrtite the complete path of the file
<% Fnm = dir & "\my_file.ext" %>
Be aware of \



Create the file
and open it at the same time!
<% set inF = FSO.CreateTextFile(Fnm) %>

or, open it in editing mode
<% set inF = FSO.OpenTextFile(Fnm,2,false) %>

or, finally open it in "append" mode
editing at the end
<% set inF = FSO.OpenTextFile(Fnm,8,false) %>

If 'true' replaces 'false' a file will be automatically created if it does not exist... so, be careful!



Then, simply write
<% inF.write texte %>

or, write a line
add VbCrLf at the end of the text
<% inF.writeLine texte %>

or, write some empty lines
<% inF.writeBlankLines(5) %>



And, finally close the file
<% inF.close %>

With PHP, it is fundamental to be sure that editing function is authorized with the folder (chmod or via FTP software)

After that,

Define the file of interest
<? $Fnm = "my_folder/my_file.ext"); ?>



Open the file in editing mode
create if it does not exist
<? $inF = fopen($Fnm,"w"); ?>

or, in "append" mode
Create if it does not exist
<? $inF = fopen($Fnm,"a"); ?>

or, in "mixte" mode
reading and editing
<? $inF = fopen($Fnm,"r+"); ?>

Eventually, point out the cursor

The position of the cursor is in:
<? $ptr = ftell($inF); ?>

and, you can modify it by typing:
<? $ptr = fseek($inF,$ptr-10); ?>




Then, simply write
<? fwrite($inF,$texte);
// or
fputs($inF,$texte); ?>


to jump to next line, write \n
<? fputs($inF,$texte."\n"); ?>



And finally, close the file
<? fclose($inF); ?>

Comments
  1. With PHP, we can edit on a remote server...

    <? $inF = fopen("ftp://login:pass@www.site.com/www/my_folder/my_file.txt","w"); ?>
Application

If you have well assimilated this presentation and the other ones, you should be able to produce something like this! If not, see detailed explanations here in...

Enjoy!

artvoila on 12/19/2003 (440 332 hits)
Didier Téléchargez gratuitement !!!
7 logiciels illimités dont Visual Studio Pro et SQL Server 2005 !
SQL Server 2008 ß !
[gratuit] 11-12-13 février
les MS TechDays 2008 !!!
Au fil des news  
Dreamweaver CS3 + XML + Ajax - Création d'une région détail
Dans cet article, je vais vous montrer comment utiliser la technique région détail, avec Spry
PHP - joli arborescence dynamique
Magazines - Le N°104 de Programmez est disponible
PHP - PhPBB 3.0.0 !!!
[MAJ] Université de Sherbrooke - située dans un beau coin du Québec, l'Estrie...
- Ajout du programme d'imagerie et de médias numérique - Le département de mathématiques et ...
Magazines - Le N°103 de Programmez est disponible
PHP - Calcul jours ouvrables entre dates, gestion fériés
PHP - WampServer 2.0, la nouvelle version de WAMP5 !
SharePoint 2007 et Workflows Designer - Part 2 - Modifions un workflow dans SharePoint 2007
Dans la première partie, nous avons vu comment créer un WorkFlow dans MOSS avec SharePoint ...
Modifier le ruban de Word 2007 avec Open XML -
Open XML est un format de document bureautique flexible : structure basée sur l'Open Packaging ...
La corbeille de SharePoint 2007 - Fonctionnement de la corbeille de SharePoint 2007
Une des nouveautés de SharePoint 2007 est la mise en place de la corbeille pour chaque site. Il est ...
SharePoint 2007 et Workflows Designer - Part 1 - Créer un workflow simple dans SharePoint 2007
L'automatisation de Workflows, ou Flux de travail, résulte d'une volonté d'amélioration de ...
CSS - Dégradé de couleur
Magazines - Le N°102 de Programmez est disponible
Dreamweaver CS3 + Mysql - Formulaire de redirection
Suite au coup de pouce de DB77, je vous propose ce petit script pour améliorer vos pages Internet. ...
[MAJ] Tutoriel AJAX simple - En avant vers le WEB2.0
Mis à jour le 26/10/2007
Magazines - Le Hors-Série .Net de Programmez est disponible
LINQ et vous - Part 2 - Le .NET Framework 3.5 décortiqué !
Ce nouvel article fait suite à mon premier article de cette nouvelle collection « LINQ et vous ». ...
Présentation des KPI dans SharePoint - Présentation des KPI dans SharePoint 2007
Nous verrons au travers de cet article une présentation détaillée de ce qu'est un KPI et dans quel ...
LINQ et vous - Part 1 - Evolutions du .NET Framework - Visual Studio 2008
Voilà plus d'un an que je n'ai plus posté d'articles sur ma communauté préférée. Il était temps ...
Agenda - 21-22 novembre : Le Forum PHP 2007 !
Microsoft - Essayez gratuitement MS Expression Studio !!!
Les Utilisateurs dans SharePoint - La gestion des utilisateurs dans SharePoint
SharePoint dont le coeur est l'outil collaboratif, Windows SharePoint Services. Chaque utilisateur ...
Magazines - Le N°101 de Programmez est disponible
Hebergement - hébergement de forum gratuit - créer un forum.
Revue de presse - Nouvelle mise à jour chez Adobe
PHP - import csv vers bdd avec verification
PHP5 - Csv2array
PHP - Framework PHP5 - PoppyFramework
Le Moteur de Recherche de MOSS 2007 - Installer le moteur de recherche de MOSS 2007
Nous avons vu dans un précédent article comment mettre en place le moteur de recherche dans un site ...
PHP5 - incrementation alphanumerique
Magazines - Le N°100 de Programmez est disponible
Agenda - Adobe vous donne rendez-vous du 4 au 9 septembre..
ABAP leçon 1 : Les variables - Auteur : Jerome Fortias
je me devais de continuer mon travail de vulgarisation à SAP. En parallèle à mon site destiné aux ...
Agenda - Nov 2007 : Les TechEd Developers à Barcelone !
Microsoft - Vista SP1 et XP SP3 pour bientôt !
Le Moteur de Recherche de WSS V3 - Installer le moteur de recherche de WSS V3
Parmi les évolutions de Windows SharePoint Services V3, on trouve le moteur de recherche. Nous ...
PHP - array2xml convertie un array en xml
Revue de presse - Flash Player 9 Update beta
PHP5 - class Timer - ajouter/enlever du temp au time unix
Tutorial : HTML | Scripting | ASP-PHP | ASP.net | SQL Server | XML
Sharepoint | XAML | Pocket | Dreamweaver | VML | Divers
  Scripts : Scripting | ASP-PHP | ASP.net | Divers
  Boutique | Annuaire | Bannières | Météo | Tribune | Partenariats
v3 © Didier 2003   
 
 DotNet Project Wygwam Codes Sources MVP El Roubio Groupes Utilisateurs Microsoft CodePPC The Inquirer FR TechNet ASP-magazine