Jump to content

Display files from local drives on webpage


kamranki

Recommended Posts

Hello everyone,

Since I'm a complete beginner, please excuse any errors or mistakes. I don't have any scripting experience to speak of but I mostly manage by copy and pasting. In most conditions, I am able to understand the syntax.

I have set up a simple webserver for uploading files. It can be accessed at:

[url=http://www.kamranki.com:1300/upload/user/upload.php]http://www.kamranki.com:1300/upload/user/upload.php[/url]

The webserver machine uses the following:

- Windows XP Professional SP2
- Abyss Web Server X1
- PHP

I would like to list local folders and their contents on the webpage so that I can access my files from anywhere. I already have an FTP server running but I would also like to access my files through HTTP. I don't need a complex setup but rather a very simple listing of files from a specific folder on the hard drive. I should be able to download the file by clicking on it's name.

I would like to know if there's a function for listing files from local folders. Any examples will do just fine. Any help would be greatly appreciated.

Thanks and regards,
Kamran
Link to comment
Share on other sites

Ive never heard of Abyss web Server but apache has a directive which allows you to list file indexes, maybe Abyss does too.

Of course if you want to display files from outside of the web root, then your going to need to write a script to do it. In which case your going to want to find a tutorial on reading directories with php.

[url=http://hudzilla.org/phpwiki/index.php?title=Working_with_files]Here[/url] might also be a good place to start.
Link to comment
Share on other sites

Here's what I was able to manage; a simple listing of contents of c:\temp on the PC. But how can I make these files downloadable? I tried looking at some other sample scripts from around the web but was unable to get anything working.  :-[

Following are the contents of download.php:

[hr]
[font=Courier]
<font face="Tahoma" size="2" color="black">

<?php

if ($handle = opendir('c:\\temp'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
echo "$file <br>";


}
}
}
?>
[/font]

[hr]

It can be accessed at:

[url=http://www.kamranki.com:1300/download/files/download.php]http://www.kamranki.com:1300/download/files/download.php[/url]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.