listing a directory files in a webapp

Discussion in 'Mac Programming' started by Sal77, May 22, 2008.

  1. Sal77 macrumors newbie

    Joined:
    May 22, 2008
    #1
    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.
     
  2. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
  3. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
  4. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
    #4
    thanks for reply

    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.
     
  5. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #5
    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.
     
  6. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
    #6
    thanks again

    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.
     
  7. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
  8. dws90 macrumors regular

    Joined:
    Jan 16, 2008
    #8
    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).
     
  9. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #9
    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
     
  10. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
    #10
    thanks

    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.
     
  11. psingh01 macrumors 65816

    Joined:
    Apr 19, 2004
    #11
    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.
     
  12. Sal77 thread starter macrumors newbie

    Joined:
    May 22, 2008
    #12
    no i am trying to find some more info how to do it but I really don't have idea how to...
     
  13. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #13
    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
     

Share This Page