Results 1 to 4 of 4

Thread: Check if new file exists!

  1. #1
    Join Date
    Jul 2011
    Posts
    54
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation Check if new file exists!

    I would like to know how/where to start to get an a ajax or JavaScript script to check if a folder filled with text files was changed and then display them according to a php File. Let me know what I can do to clarify!


    Thanks so much for your help!

    -M2com

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by M2com View Post
    I would like to know how/where to start to get an a ajax or JavaScript script to check if a folder filled with text files was changed
    changed since when?
    where is the folder?

    Quote Originally Posted by M2com View Post
    and then display them according to a php File.
    I'm not at all sure what you mean by that.

    Can you describe and/or give examples of what you want to happen?

  3. #3
    Join Date
    Jul 2011
    Posts
    54
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply!

    I mean if it was changed at any time, past year or the past couple seconds. The folder that is filled with text files Is located in the same directory that this script I'm asking about is.

    The php script/file will format the information from the text files how I want it and give it the functionality I want, it's like a Facebook status feed.

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    JavaScript would not be able to do this. You'd need to use PHP (or another server-side language) - I'd suggest learning about the filemtime() function.

    To expand on my "changed since when" question, checking if has changed "at any time" will not be very useful. If the file exists, that means it has been changed at least once. Same if it once existed but does not any longer. The only was a file will have not changed, ever, is if it never existed at all.

    SO, you need a "since when" constraint. What timeframe are you checking against? I would suspect you want to check if there was any change "since last time I checked," meaning you'd also need to keep track of when you last checked.

    It would make sense for your "checking" script to control your formatting script.

    Now, JavaScript/AJAX can send an HTTP request to your PHP script, triggering this whole process. You'd need to decide how you want the information returned (JSON might be a good idea).

Similar Threads

  1. How to check whether the input is file
    By probyte2u in forum PHP
    Replies: 2
    Last Post: 09-16-2012, 07:54 AM
  2. Ajax javascript test if image file exists
    By Strangeplant in forum JavaScript
    Replies: 1
    Last Post: 12-12-2007, 04:28 PM
  3. Ajax Test for File Exists?
    By Strangeplant in forum JavaScript
    Replies: 3
    Last Post: 11-13-2007, 04:00 PM
  4. Only display link if PDF file exists
    By jcarr in forum Looking for such a script or service
    Replies: 2
    Last Post: 05-04-2007, 09:55 AM
  5. Display Link if file exists
    By jcarr in forum HTML
    Replies: 3
    Last Post: 03-08-2006, 02:54 PM

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
  •