View Full Version : listing a directory files in a webapp
Sal77
May 22, 2008, 05:32 AM
hi everyone,
I am new to this forum and also quite new to programming and dash code.
I am trying my first webapp for iphone to stream video files from a webserver, till now I can stream the files into iphone but using direct paths that lead to the files, but I want to create a dynamic list to automatically update the list of files when and if I add or delete some of them.
I need some help cause i can't get to list the names of files contained in a directory inside the webserver, to be displayed inside an edge-to-edge list.
Sal77
May 22, 2008, 08:16 AM
anyone who can help me?
Cromulent
May 22, 2008, 08:38 AM
Which language are you using? PHP?
Sal77
May 22, 2008, 08:44 AM
I would like to use javascript but seems quite hard for me, so any other solution is highly appreciated.
I am using dashcode and created a webapp from custom template, and working with a edge-to-edge list.
Cromulent
May 22, 2008, 09:18 AM
I would like to use javascript but seems quite hard for me, so any other solution is highly appreciated.
I am using dashcode and created a webapp from custom template, and working with a edge-to-edge list.
I know very little about Javascript but I would be very very surprised if there was not a function for doing this in its library somewhere. Just look for something that lists directory contents and print the output to the HTML page.
Sal77
May 22, 2008, 09:40 AM
My problem is how to collect the names of files on that folder and to use those inside a ui list in dashcode (edge-to-edge list), I think I should create an array but not so sure.
Sal77
May 22, 2008, 11:07 PM
anyone who knows how to solve this?
dws90
May 23, 2008, 12:27 AM
JavaScript is client-side, and therefore isn't really meant for listing files on a remote server. Although I imagine it's conceivably possible, using a client-side language to access the server is a bit silly.
You really want to look into a server side language like PHP or Perl (PHP's easier to pick up and use). If you still want to make the interface, you can use JavaScript to call the server-side script (AJAX).
lee1210
May 23, 2008, 12:48 AM
this is definitely a server side job. You just need to generate a list of li elements or some other html element on the server. What language you do this in will depend on your server. For a task like this anything will work. Don't worry with trying to get the items via AJAX. I doubt the video list will change so often that clients will need to be refreshing "dynamically".
What kind of server is this on? Are you familiar with perl, php, C, etc.?
-Lee
Sal77
May 23, 2008, 01:32 AM
The server is apache, I need the dynamic feature because files will be uploaded on a daily basis. I am a bit familiar with C but never used other, I am an hobbist on this.
psingh01
May 23, 2008, 04:42 PM
I'm pretty sure php can read the files in a directory on the server side. Have your javascript make a request a php page that outputs the file names.
Sal77
May 24, 2008, 01:17 PM
no i am trying to find some more info how to do it but I really don't have idea how to...
lee1210
May 24, 2008, 02:53 PM
http://us2.php.net/function.opendir
This page describes the function you need to use to get a directory handle and enumerating the files should then be trivial. Once you have this piece done, it should be pretty straight-forward to turn them each into an href in an li.
-Lee
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.