Solved

all the filenames as links I can click on

Posted on 2013-11-05
3
199 Views
Last Modified: 2013-11-07
Using php, I want to list all the filenames in a folder as hyperlinks


folder
<a href="file1.wmv" target="_blank">file1.wmv</a>
<a href="file2.wmv" target="_blank">file2.wmv</a>
<a href="file3.wmv" target="_blank">file3.wmv</a>
0
Comment
Question by:rgb192
3 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39624323
Something like this:

<?php 
$folder    = '.';
$files = scandir($folder);

foreach ($files as $file):
	printf("<p><a href='%s' target='_blank'>%s</p>",$file, $file);
endforeach;
?>

Open in new window

0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39624392
No points for this, but... You may want to filter the list of files a little bit, in case your process is not the owner.
0
 

Author Closing Comment

by:rgb192
ID: 39629570
This will work for displaying all the filenames

Thank you

A related question has filenames with spaces

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28287715.html
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses four methods for overlaying images in a container on a web page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question