rgb192
asked on
want foldername and full filename in the hyperlink
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>
This code does not include foldername and does not work for filename with spaces (only includes the filename before the space
00 01.filename with spaces.wmv
00 02.another filename with spaces.wmv
folder
<a href="file1.wmv" target="_blank">file1.wmv<
<a href="file2.wmv" target="_blank">file2.wmv<
<a href="file3.wmv" target="_blank">file3.wmv<
<?php
$folder = '.';
$files = scandir($folder);
foreach ($files as $file):
printf("<p><a href='%s' target='_blank'>%s</p>",$file, $file);
endforeach;
?>
This code does not include foldername and does not work for filename with spaces (only includes the filename before the space
00 01.filename with spaces.wmv
00 02.another filename with spaces.wmv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Suggestion from the voice of experience... Never leave a blank in a file name. Use letters, numbers and the underscore, nothing else, and you will save yourself from a lot of strange "edge case" headaches!
Suggestion from the voice of experience... You often don't have the choice ;)
Yeah, that's part of what's wrong with the Obamacare web site!
ASKER
first.: I see
+ instead of space (which I think is %20%)
second:
the 'folder is not in the url'
which would force me to put the file in the directory
I want to put the file outside the directory
(I am not sure if I asked for this, so this may be another question.)
+ instead of space (which I think is %20%)
second:
the 'folder is not in the url'
which would force me to put the file in the directory
I want to put the file outside the directory
(I am not sure if I asked for this, so this may be another question.)
+ is a URL-Encoded space. Can also be %20.
I may be able to give you a general purpose example later -- gotta run now.
I may be able to give you a general purpose example later -- gotta run now.
ASKER
+ in browser url does not work for me
Please post the SSCCE that demonstrates the issue, thanks.
ASKER
Thanks for the url encode which is the requirement of the question.