php downloading

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
wheelspinner99
-


Joined: 23 Jul 2003
Posts: 12

PostPosted: Mon Jun 14, 2004 5:39 pm    Post subject: php downloading Reply with quote

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 View user's profile Send private message
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Mon Jun 14, 2004 6:01 pm    Post subject: Reply with quote

Would you mind showing us the website? Or at least an example of the code and the link URLs?
_________________
Bienvenidos!
Back to top View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Jun 14, 2004 8:22 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
wheelspinner99
-


Joined: 23 Jul 2003
Posts: 12

PostPosted: Tue Jun 15, 2004 7:52 am    Post subject: Reply with quote

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 View user's profile Send private message
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Tue Jun 15, 2004 7:57 am    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
wheelspinner99
-


Joined: 23 Jul 2003
Posts: 12

PostPosted: Wed Jun 16, 2004 8:08 am    Post subject: Reply with quote

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 View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Wed Jun 16, 2004 8:31 am    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Wed Jun 16, 2004 7:10 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
wheelspinner99
-


Joined: 23 Jul 2003
Posts: 12

PostPosted: Thu Jun 17, 2004 7:28 am    Post subject: Reply with quote

ok, thanks for breaking that down for me. It works great now! Thanks for everybodies help.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group