Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Edit .txt file on server

  1. #1
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default Edit .txt file on server

    I know you can edit text files with ActiveX on your comp., but I'm wondering if this can be done on a server (FTP). I completely threw away the idea of a MySql database, so I'm trying to find an alternate route. Thanks
    - Mike

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Using FTP, I've always just edited the file then uploaded it. You can open and do relatively simple operations to text files and close them using asp. With a little creativity, this could be 'editing'. PHP includes the same basic, if not more, functionality in this regard, as far as I know (not much experience with PHP or asp but, I have messed with text files using asp and it works.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I want the user to be able to do it -- to have a page where the user can do it dynamically. I understand what you're saying though, and thanks.
    - Mike

  4. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    My server won't let me use asp though, so I'll have to look into PHP.
    - Mike

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There's no need to use FTP. A script on the server will (presumably) be running as the user to whom the file belongs, and so will have read and write access to it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In your last thread on this topic I mentioned a free PHP add-on that allows editing and more. From what it says on the info page, you can control who gets to edit and what files are available to edit. Here is the URL again:

    http://www.phpxplorer.org/phpXplorer/webIndex.php

    I'm not recommending this, haven't used it but, looks promising and it is free.

    I'm sure it must be possible to work out a simple editor by importing the text of a text file to a textarea, editing it there, and then submitting it to a page that would then write the new value to the same text file (perhaps, if need be, deleting the old version first). The program I mention above is much more involved but, presumably they have already worked out most of the details. It may require access to the server to install it though.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yeah. I saw that, but I couldn't get it to work. I posted my question this time, in a different way to try to get some different answers.
    - Mike

  8. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Argh... My webhost disabled system() and exec() commands in PHP. So I can't even do that. This is horrible. Are there any alternatives to system() ?
    This is the dos line I used:
    Code:
    echo test > test.txt
    - Mike

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    try fopen()

    if that fails, then you likely won't be able to do anything with files.

    But, if it works, then you can open the file into a variable and edit it all you want, then use fwrite() to save it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Okay. Thanks djr33
    - Mike

Bookmarks

Posting Permissions

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