View previous topic :: View next topic |
Author |
Message |
wheelspinner99 -
Joined: 23 Jul 2003 Posts: 12
|
Posted: Mon Jun 14, 2004 5:39 pm Post subject: php downloading |
|
|
i have a simple dl page on a website i am building. It simply shows all files available in the specified directory and creates a dl link. I use a upload page to populate this folder, which works great! The problem is that i can see the correct files in the dl page but when i click them i get a 404 error. I physically check the folder and the files are there and i even checked the outputed html code and made sure the links were setup correctly, which they were. Where can i go from here? thanks! |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Mon Jun 14, 2004 6:01 pm Post subject: |
|
|
Would you mind showing us the website? Or at least an example of the code and the link URLs? _________________ Bienvenidos! |
|
Back to top |
 |
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Mon Jun 14, 2004 8:22 pm Post subject: |
|
|
I believe you have your files listed out of the web root and in that case
they will show up as 404 Not Found , you should create an aliases to that
folder so they can be reached from the server , they can easily be listed
because PHP has the power to do that but they must be reached by the
web server in order for them to download properly. Did This Fix it ? |
|
Back to top |
|
 |
wheelspinner99 -
Joined: 23 Jul 2003 Posts: 12
|
Posted: Tue Jun 15, 2004 7:52 am Post subject: |
|
|
here is both the code and another question.
<HTML>
<?PHP
$dirname = "C:\\MovingFiles"; #change this to accept a variable and be able to DL from any folder
$dir = opendir($dirname);
$file_list = "" ;
$rec = 0 ;
while(false != ($file =readdir($dir))){
if (($file != ".") and ($file != "..")){
$file_list .= "<A HREF= \"$dirname\\$file\">$file</A> <BR>" ;
$rec = ++$rec;
}
}
closedir($dir);
?>
<BODY background = "Backgrounds\SWIRLRAY.JPG" text=white link=white vlink=white>
<CENTER><CENTER>
<h3>Files available for download in Oracle folder<BR><?PHP echo($dirname)?></H3>
<A HREF="secureLogin.php" ><IMG SRC="PicBin\SecureLogin.jpg" border=0></A></CENTER>
<HR>
<h4>File listing:</H4>
<?PHP echo($file_list); ?>
</CENTER>
</BODY>
</HTML>
The folder is out of the root. I am having a hard time setting up the alias for this folder. How is this accomplished? The folder is C:\MovingFiles abyss is C:\program files\Abyss\htdocs. Hope this helps! |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Tue Jun 15, 2004 7:57 am Post subject: |
|
|
That's your problem. Set up an alias in Abyss so C:\MovingFiles (the real path) is /movingfiles (the virtual path). Then change $dirname to "/movingfiles" and it should work. _________________ Bienvenidos! |
|
Back to top |
 |
 |
wheelspinner99 -
Joined: 23 Jul 2003 Posts: 12
|
Posted: Wed Jun 16, 2004 8:08 am Post subject: |
|
|
ok, i created the alias just like that. As noted in the code above C:\\movingfiles is already the target folder so i didn't change anything there. Still 404 error. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed Jun 16, 2004 8:31 am Post subject: |
|
|
Instead of using the $dirname , use /movingfiles and
it should work , you have it pointing to a local directory
that is not from the web server , the correct code.
Code: | <HTML>
<?PHP
$dirname = "C:\\MovingFiles"; #change this to accept a variable and be able to DL from any folder
$dir = opendir($dirname);
$file_list = "" ;
$rec = 0 ;
while(false != ($file =readdir($dir))){
if (($file != ".") and ($file != "..")){
$file_list .= "<A HREF= \"/movingfiles/$file\">$file</A> <BR>" ;
$rec = ++$rec;
}
}
closedir($dir);
?>
<BODY background = "Backgrounds\SWIRLRAY.JPG" text=white link=white vlink=white>
<CENTER><CENTER>
<h3>Files available for download in Oracle folder<BR><?PHP echo($dirname)?></H3>
<A HREF="secureLogin.php" ><IMG SRC="PicBin\SecureLogin.jpg" border=0></A></CENTER>
<HR>
<h4>File listing:</H4>
<?PHP echo($file_list); ?>
</CENTER>
</BODY>
</HTML>
|
|
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Wed Jun 16, 2004 7:10 pm Post subject: |
|
|
iNaNimAtE wrote: | Then change $dirname to "/movingfiles" and it should work. |
Like this:
Code: | <HTML>
<?PHP
$dirname = "/movingfiles"; # << That has been changed
$dir = opendir($dirname);
$file_list = "" ;
$rec = 0 ; |
I said it earler, but I guess you didn't do it for some reason... _________________ Bienvenidos! |
|
Back to top |
 |
 |
wheelspinner99 -
Joined: 23 Jul 2003 Posts: 12
|
Posted: Thu Jun 17, 2004 7:28 am Post subject: |
|
|
ok, thanks for breaking that down for me. It works great now! Thanks for everybodies help. |
|
Back to top |
|
 |
|