Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do i save db field data to a file on the server?

    Hi,

    I have a form full of data that needs to get saved in a db - not a problem.

    What i now need to do is find a way where, one of fields in one table points to a file in a folder on the server . Now this file is a doc file - a report that gets updated all the time by different users.

    For simplicity, lets say, this form holds address data of 10 persons. Now lets assume they change homes frequently and since each knows the address of the other, the street field in Record A, originally entered by User A, can be modified by User B and then posted back to its place . Similarly, Users C and D can change the street name but Users E-J can only view the addresses but not edit it.

    Now all street field data is stored in public/html/domain/Addresses/England folder on the Server and the file they are stored in is Engadd.doc . I need to be able to call Engadd.doc and then have the records added, modified or viewed.

    I'm pretty much set for most of this code but I'm not sure what kind of syntax to use to be able to call,edit and then upload both $street and Engadd to its place.

    The possibility of doing and INSERT or UPDATE $street = $_POST["street"]; is not on because that only saves $street in the table field but not in the file on the folder.

    Would anyone guide me on this please ?

    Thanks !
    Swati

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Sooo.... you just need to know how to edit a file? If it is a text file then you should be able to do this. (won't work if it's a Word file.) Open the file using fopen() with a mode of "r+" which means you can read and write the file. You'll then have to read through the file sequentially and use fwrite() to change records as you see fit.

    I sometimes just read an entire file into an array using file(), then re-create the file by using mode "a" with fopen, parsing through the array and fwrite() as I go, changing what I need to change along the way.

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    145
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i need to edit AND store it on the server in a folder . And it is doc not text...and that i cannot change . These are word forms. The rest of the related data remains as fields of a record in a db table. Just this one field will point to a folder on the server.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •