Results 1 to 3 of 3

Thread: upload folder

  1. #1
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default upload folder

    does anyone have the script that would read from a folder files that are in it and post them on the page?

    so if i upload a file to say movie folder and i want it to post on my video download page what would i use for a code to pull from the movie folder?

    im really new to trying this stuff so please be easy with me

    thank you very much.

  2. #2
    Join Date
    Sep 2007
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    any help please i knows its easy just cant gigure it out

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP is the best solution here [or maybe another server side language, but I'd go with PHP].
    Can't do this with html or javascript alone.

    PHP Code:
    <?php
    $dir 
    'my/videos/folder/'//set directory
    $d opendir($dir); //open for use
    while ($f readdir($d)) { //loop through for each file returned
       
    if ($f=='.'||$f=='..') { continue; } //skip iteration and continue loop if the file is the current dir or parent dir
       
    if (!is_file_type_I_want($f)) { continue; } //skip if the file type doesn't match***
       
    echo $dir.$f//output the directory/filename.
    //end loop
    ?>
    That's a basic example, but it gives what you need.

    ***is_file_type_I_want() will need to be replaced with a real function.
    !function() means "if false", so you can use !getimagesize() to see if it is an image, and if not, skip.
    For videos, it's a bit harder. You could check the extension, but that isn't always true since any file could be renamed to a certain extension. I'm not really sure what to recommend in that case.
    You could also just know that all files are valid in there and nothing will show up incorrectly, except for . and .., or you could add some specific folders/files to that list, like
    if ($f=='.'||$f=='..'||$f=='index.htm').

    Hope this gets you started.



    [Your other thread has been deleted. Do not post twice for a single question.]
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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