New Version: Ajax File Browser 2.0 Beta, this version is no longer supported.
As the new buzz technology is developing, I realized I had no real evidence that I in fact know how to use it. Coupled with the need for an intranet file server application, I decided to make an Ajax version of a Server File Browser.
Using the Sarissa ajax library, this handy application only has a page weight of 71kb! Directory listings are limited to 30 files/folders per page, so the ajax requests are quite quick. Additionally, the application has been tested on Firefox and IE 6 only. Please leave me a comment if you have bugs with other browsers.
All shared files can be downloaded, and are force saved. Meaning that you can even share your PHP source files, without letting them be compiled first.
Application Configuration
After downloading the application, unzip the contents to a directory on your webserver. This application has been designed for a host where the PHP document root is the root path of the application. So, it cannot work under a sub-directory of a domain or host name. You may want to look into sub-domains if this affects you.
The application requires no database (although may do so in future, to log downloads etc). There is only one configuration file, config.inc.php. In this file there are two main settings:
Paths to directories on the server. They do not have to exist as a sub-directory of the application, they can exist relatively or absolutely. So long as the web service has permissions to the directory, you can browse it. This is the biggest reason why I had to write my own application. Others on the net simply didn’t allow complete server browsing. You must be careful not to share anything crucial or anything that will compromise server security. Once a directory is shared, all sub-directories will also be shared. Blacklists
You can exclude certain directory names, file names, and even file extensions from being viewed. I was also going to include something about hidden or system files as well, but I got lazy :)
Apache vs Other Servers
Included in this package is a .htaccess file for Apache servers. It’s main directive is to prevent PHP’s short open tags. If you have an error with the .htaccess file (as some servers will not allow PHP values in them) then you will have to make arrangements to prevent the short open tag in another way. The short open tag will affect the XML documents returned with the Ajax calls. This directive is now irrelevant in v1.1
Demo and Download
Changelog
![[image]](http://mowser.com/img?url=http%3A%2F%2Fblog.jc21.com%2Fwp-content%2Fplugins%2Fsociable%2Fimages%2Fmore.png)
![close [image]](http://mowser.com/img?url=http%3A%2F%2Fblog.jc21.com%2Fwp-content%2Fplugins%2Fsociable%2Fimages%2Fcloselabel.png)
This scripts is great! Ajax Rox
Hi,
been trying to run it on my server it dun work :( , how do i install it.
I have a directory called documents.
Please Help :(
How exactly doesn’t it work? Does the page load correctly, but the loading graphic hangs when you select a share?
It loads correctly on my linux server however hangs when you select a share?
Is this only for windows file systems??
Not at all. The demo hosted here is running on Linux with php 4.4.3.
I’ve also tested it with php 5 and IE7 RC1 with no troubles. If the share folder didn’t exist, or couldn’t be found you would be notified with a message box. The only way the hanging should occur, is if there was an error with the XML data that gets returned. And the number one error there is the PHP Short Tags problem.
I’ve fixed up a bit of the code that requires PHP short tags to be off, and now it doesn’t matter. The new version (1.1) is available from the link above.
If the application still hangs on the waiting screen, try entering this in a new window:
http://host/_ajax.php?share=1
and if there is a problem with the XML return data, you’ll see it there. If not, you’ll see a well formed XML document.
Thanks for the quick fix! I’ll try it out….
Works! Great Ajax Script!
Hey,
Thank you for the script it works great now :) , thanks for all the help :)
can it show the number of times a file has been downloaded next to the file size?
Not without a database, or xml, or text file storage system. The trouble with logging downloads, is that files may be deleted on the filesystem, and the records of their download would still be in the database. So you’d have to execute a cleanup script once in a while so you only have relevant data. Assuming that’s ok, you would next have to log downloads, and compare the existing records by a md5 or similar, no 2 files are under the one record in the database. It’s some tricky stuff, and something I’d like to do, and probably will. When that time comes, I’ll re-release the script under something else, and may include an admin part so you could delete and upload files too.
The question is, what should the new script be called?
Researched my way into dynamically adding a Directory List on the Left nav :D. here is the code
$shares = array();
//copy one of these array difinitions and modify.
$dir = “../dirname/”;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle)))
{
$fileext = substr(strrchr($file, “.”), 1);
if($file!=”" && $file!=”..” && $fileext==”" && $file!=”.”)
{
$shares[] = array(
‘name’=>$file,
‘title’=>$file,
‘path’=>’../dirname/’.$file
);
}
}
closedir($handle);
}
What do you think ??
Very good, it’s one way you could go about it. When in the while loop though, I would add another check so that you are sure you are listing directories and not files aswell (incase someone copies a file there by accident). try:
if (is_dir($dir.$file)) {
//is a directory, add to shares array here.
}
Is it any way to amend the code to work on Chinese character on windows system ? Cause if encounter file name with Chinese character, it become wierd. Thks.
I have no idea how to deal with chinese characters… or any non-ascii stuff. sorry
Hi,
We get a mouse over on the left nav, how do i disable that :( which says javascript void something :(
What browser, in what operating system are you using? And, are you getting the error when you view http://ajaxfb.jc21.com/ ?
I’ve tested that site on IE 6 and 7 and Firefox on Windows XP, with no errors.
I think I know what it could be, but I want to be sure first.
If you are using a different combination of software, can you give me as much information about the error as possible. Thanks.
how do i or can i add restricted access /users to it?
Using this code, you could apply a htaccess restriction to the page, but I’ll give you some inside info. I’m currently working on an improved edition of this, hopefully encompassing all the requests so far. Some major features would be:
* A database to store settings, statistics. With a self install script
* Anonymous and named user accounts with permissions per user, per share
* Administration section – no need to edit config files.
* Permissions for shares: View, Download, Delete, Upload
I’d say I’m 30% complete with this new software, and I can’t give a release date. But to prove I am doing it, here’s a screenshot of the admin: http://blog.jc21.com/wp-content/screenshots/afb_demo.jpg
I’m still struggling with a nifty application name…
Great script with very nice visuals. However it has some bugs. For example download doesn’t start if the filename comtains an ‘ (apostrophe).
Oh yes, and internationalization isn’t supported. With ISO-8859-2 (which doen’t differ much from standard English charset), the script fails. But, after all, this is a great work and I’m badly waiting the next version :)
Nice app – and I like Michael’s dynamic folder view on the left.
What would be nice is to have the option of a tree view on the left, so that each time you enter a folder, the nav tree is updated with the new folders.
looking forward to the new version :)
This is a great tool, I tried the demo and its WOW. But I tried to use it locally and I got this:
http://img520.imageshack.us/img520/6244/filebrowserzd2.jpg
Could you please help me fix it?
[...] After the success of the PHP Ajax File Browser V1.1, I’ve re-invented the wheel with this new version. It’s not just a simple file browser anymore! [...]
is there any way to add thumnail support in a grid?
I´m Portuguese (Lisbon) , but now i live in Brazil (Itumbiara).
Congratulation for your Script AJAX FileBrowser, it´s the best scripts that i see .
Thank you for the script it works great.
When i found the Portuguese Language ?
Can i translate the script for the portuguese lang. ?
When I introduce Language Support, perhaps you can contribute your own language file. As the Christmas holidays get closer though, I won’t have much time at all to spend on this project…
Hey JC,
I’ve commented about previewing files before, and constantly check for sweet updates. I was just finishing up fantasy football with espn, and thought about roll over type of image preview like espn does. Images could roll over as you roll over the file links. That would be pretty slick. Anyway, just a thought.
Thanks,
Victor
I’ve thought about that too. I think I’ve seen it in another file manager app before.
thanks for your great code.
After successful installation, I can’t not login with the user and password I created before (The user and password are both correct, I can see it in my Database).
Do you have any idea?
try revisiting the site after closing the browser. the link supplied in the installation seems to be incorrect.
I have little problem. I can’t logon i insert my user/pass it’s loading a little bit and trows me back why ???
Same problem here as btkk and G Tibi. I installed it but cannot login.
Hi,
I am not able to download the zip from the given link…
http://blog.jc21.com/2006-08-21/php-ajax-file-browser/
Let me know the correct link for downloading..
Thanks in advance..
Hoe the link is http://blog.jc21.com/files/ajaxfb_1-1.zip
Hi, can your script show the contents of a subdirectory as well. I need a script that can be activated from a flyout menu so in other words, set the path to the parent directory in the menu and when the user activates the menu, the file browser would show a list of all files, in this case PDF files in the parent directory, as well as files in the subdirectory and allow them to be opened or downloaded.
Thanks
Dave
I was just finishing up fantasy football with espn, and thought about roll over type of image preview like espn does. Images could roll over as you roll over the file links.
Really good this thanks for share
Thanks for help
Thanks for usefull information