I am trying to work on creating a downloading share where a user will place a file in a share for users to use via a web browsing app.
My viewing page code is as follows:
[php]
Download Form <?php $User_path = $_SESSION['profilepath']; $myDirectory = opendir($_SESSION['profilepath']."/"); $User_folder = $_SESSION['userName'];while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount = count($dirArray);
if ($indexCount - 2 == 1) {
Print (“1 file
\n”);
}
if ($indexCount - 2 == 0) {
Print (“You do not have access to any files at this moment. .”);
}
else {
Print ($indexCount - 2 . " files
\n");
}
sort($dirArray);
print("
| Filename | Filetype | Filesize |
|---|---|---|
| <a href=".base_url().$User_path."/".$dirArray[$index].">$dirArray[$index] | ");
?> [/php] I seem to have 2 issues with this so far. issue 1 is that if a file is listed with a name like 'Murphy Test File.txt' the resulting link listed is shown as /path/to/file/Murphy the variable $dirArray[] should list all files in the path. how could i go about having it change the whitespaces to something such to read such as 'Murphy\ Test\ File.txt'.
Issue 2.
When clicking the link to the file. it is attempting to open a new page instead of downloading the file.
Please help.