-
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.
-
any help please i knows its easy just cant gigure it out
-
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.]