jquery file tree- how to parse file path?
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
Why give a link to an invalid location? Change the link path using php to the correct path.
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."
It still makes no sense to give an invalid file name.
newRel = oldRel.replace(/home\/cityofligonier\//, "");
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.
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 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?
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.
window.location = file;
Hope this helps.
window.location = file.replace("/home/cityofligonier","");
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?
No problem. Try this for opening in new window:
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...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)