View Full Version : How to create a download page automatically


Blade328
03-05-2004, 07:05 PM
Hi people....

Need some help if possible. Say I upload 50 files to my website in the first instance with a view to uploading more files in the near future;

Once they are there, I want to make them available for downloading. I do not want to do this manually. What I would like to happen is this;

'Download' directory is scanned (and fifty files found); download pages are created automatically, each displaying 5 files listed in alpha-numeric order;

I would also want a next and previous button arrangement for navigating through the pages. When I upload more files, I would like the same 'code' to add more pages as required.

Is it also possible to display the total number of pages of downloads available or possibly dsiplaying all the page numbers at the bottom of the page as links?

I would also want the download pages to be displayed in a particular frame on my web page.

Any help would be welcome on this as I have not got a clue how to start and what code to use. Are there generic scripts available to do this type of thing?

Thanks in advance :)

Blade328.....

Dude128
03-06-2004, 02:13 AM
first of all, what server side programming languages do you have available to you? (for example, PHP, Perl (CGI), ASP, ...)

Blade328
03-06-2004, 04:05 AM
first of all, what server side programming languages do you have available to you? (for example, PHP, Perl (CGI), ASP, ...)

Erm... not sure.... I have DreamWeaver MX so I would say PHP or ASP to be on the safe side?

Blade328

pb&j
03-06-2004, 06:01 AM
no, not what program you use to create pages with.
your online host area.
check their FAQ or HELP pages to find out what coding types they allow or not.

Blade328
03-06-2004, 10:21 AM
no, not what program you use to create pages with.
your online host area.
check their FAQ or HELP pages to find out what coding types they allow or not.


OK... did not explain myself well there.... PHP is enabled on the server.

Looking forward to any help that is on offer..... :)

Thanks in advance.

Blade328

Jugarn Jax
03-06-2004, 02:13 PM
I didn't have time to proof this, but try it on your server:


<?php
//example: ./downloads/
$directory = 'your_directory_here';

// Directory read based on file extension
if($dir = opendir($dir))
{
while(($files = readdir($directory)) !== false)
{
if(substr($files,-4) == '.zip') //Or whatever extension you want
{
echo $files.'<br />';
}
}
closedir($dir);
}


// Directory read all non-folder files
if($dir = opendir($directory))
{
while(($files = readdir($dir)) !== false)
{
if($files != '.' && $files != '..' && file_exists($directory.$files))
{
echo $files.'<br />';
}
}
closedir($dir);
}?>


name the file index.php (or whatever extension your server uses for php) and it should work

Blade328
03-06-2004, 06:53 PM
[QUOTE=Jugarn Jax]I didn't have time to proof this, but try it on your server:

Thanks for the code.... I will check it out.

Thanks again... Blade328