Results 1 to 11 of 11

Thread: jquery file tree- how to parse file path?

  1. #1
    Join Date
    Mar 2011

    jquery file tree- how to parse file path?

    Hi guys,

    I have set up a script on my page which automatically reads the files in a specific directory on the server and displays them in a nice file tree on my website so users can download the files. Here is the script: http://abeautifulsite.net/blog/2008/...ery-file-tree/

    Here is the script in action on my website: http://ligonier-in.org/onlineservice...ents_test.html

    The plugin is working fine as far as finding the files and displaying them. However, the root folder where the files are stored is not the directory you would go to to access the actual files.

    Long story short, the script is trying to download the file at

    I need to 'parse' that url and force it to download the file from:

    Do you understand what I mean? I pretty much fumbled my way through this whole thing and to be honest I am proud of myself for getting this far. LOL

    I know nothing about javascript and it would be great if someone could spit out a code for me to copy and paste!


  2. #2
    Join Date
    Apr 2003
    Why give a link to an invalid location? Change the link path using php to the correct path.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Mar 2011
    In order for the files to display, I have to use the root of /home/cityofligonier/files/

    If I simply change the root to /files/ (which is where I want it to link to) it does not work.

    Here is where I got the idea that it needs to be parsed-

    About 3/4 down the page it says:

    "You might have to write a function to parse the filename that it passes and make some adjustments so it redirects to the right file on the server, but it will work."

  4. #4
    Join Date
    Apr 2003
    newRel = oldRel.replace(/home\/cityofligonier\//, "");
    It still makes no sense to give an invalid file name.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  5. #5
    Join Date
    Mar 2011
    I'm probably just not explaining myself very well. Or it could be I went about it all wrong to begin with. LOL

    The jquery file tree automatically grabs all of the files in the specified directory for me. So I do not have to do ANY coding when I add files such as meeting minutes, etc. All I do is upload it to to the server and it is automatically displayed in a nice little file tree for the user to download.

    But you have to specify the full root in the code which is not the same path that you would use to access the file.

    For example,
    my index page is /home/cityofligonier/index.html

    So when you go to http://www.ligonier-in.org/index.html, that is the same thing.

    But if you were to try to go to http://www.ligonier-in.org/home/city...ier/index.html, you won't get anything.

    I don't know any other way to explain it, simply because I am not that well versed on any of this.

    Can anyone help?

    I could probably try that javascript code, but I have no clue where to insert it. LOL.

  6. #6
    Join Date
    Mar 2011
    I have temporarily solved this problem by copying all of the files from /files/documents_and_forms/ to /home/cityofligonier/files/documents_and_forms.

    However, this is not ideal because now I have to upload each new file to two different directories.

    It would be nice if there was at least a way to automate that process. Can you sync two folders on a remote server? So everything I upload to one directory automatically gets copied to the other?


  7. #7
    Join Date
    May 2011
    I registered for this site just to help you out. I too just implemented jquery file tree on a site and ran into the same problem you have. I am not a web developer/programmer, but I work with one and he was able to help me so I am passing it on to you. It is a simple fix.

    Your code:
    window.location = file;
    Replace with:
    window.location = file.replace("/home/cityofligonier","");
    Hope this helps.

  8. #8
    Join Date
    Mar 2011
    Thanks so much! I really appreciate you taking the time to help me out. This is exactly what I needed!

    Since I'm feeling lucky now, any ideas on how I can get the files to open in a new window?

    Thanks again!

  9. #9
    Join Date
    May 2011
    No problem. Try this for opening in new window:


  10. #10
    Join Date
    Mar 2011
    works perfectly! I can't believe how hard it is to find this stuff via a google search. I have been looking for that simple solution for weeks!

    Thanks again for taking the time to help me. That should do it for this project...

  11. #11
    Join Date
    Jul 2012
    @Any of the OPs in this thread: I have same problem except for one thing. Nowhere in my javascript is there a piece of code that matches "window.location = file;". SO I don't know where to apply the fix! I am using (as near as I can tell) the same code from abeautifulsite.com. How can it be so different? I have the identical problem that fought70 was having. Any suggestions would be seriously appreciated! -c-

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12248 seconds
  • Memory Usage 2,944KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates