Jump to content

Recommended Posts

Hey all,

 

this kinda relates to my upload script problem but in some what way different I have now created a download script a small one that pulls the details of the files that where uploaded and places them with a link in a html table, now it creates the link ok but when I click the link nothing happens?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>View File</title>
   	<style type="text/css" title="text/css" media="all">
.error {
	font-weight: bold;
	color: #C00
}
</style>
</head>
<body>
<p>Click a file to download</p>
<table align="center" cellspacing="5" cellpadding="5" border="1">
<tr>
<td align="center"><b>File Name</b></td>
<td align="center"><b>File Size</b></td>
</tr>

<?php

/**
* @author ohyeah
* @copyright 2011
*/
$dir = 'C:/wamp/uploads/';
$files = scandir($dir);

foreach($files as $filedownload){
    if(substr($filedownload, 0, 1) != '.'){
        $file_size = round((filesize("$dir/$filedownload")) / 1024) . "kb";
        $filedownload = urlencode($filedownload);
        echo "\t<tr>
        
        \t\t<td><a href=\"$dir$filedownload\">$filedownload</a></td>
        \t\t<td>$file_size</td>
        \t</tr>\n";
    }
}

?>
</table>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/240718-download-link-problem/
Share on other sites

try this

<?php

/**
* @author ohyeah
* @copyright 2011
*/
$dir = 'C:/wamp/uploads/';
$files = scandir($dir);

foreach($files as $filedownload){
    if(substr($filedownload, 0, 1) != '.'){
        $file_size = round((filesize("$dir/$filedownload")) / 1024) . "kb";
        $filedownload = urlencode($filedownload);
        echo "\t<tr>
        
        \t\t<td><a href=\"{$dir}{$filedownload}\">$filedownload</a></td>
        \t\t<td>$file_size</td>
        \t</tr>\n";
    }
}

?>

Hey all this is my source html source code that is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />

<title>View File</title>

   	<style type="text/css" title="text/css" media="all">

.error {

	font-weight: bold;

	color: #C00

}

</style>

</head>

<body>

<p>Click a file to download</p>

<table align="center" cellspacing="5" cellpadding="5" border="1">

<tr>

<td align="center"><b>File Name</b></td>

<td align="center"><b>File Size</b></td>

</tr>



<tr>

        

        		<td><a href="C:/wamp/uploads/101_LPIC1_Mega_Guide.zip">101_LPIC1_Mega_Guide.zip</a></td>

        		<td>753kb</td>

        	</tr> 
<tr>

        

        		<td><a href="C:/wamp/uploads/Blue+hills.jpg">Blue+hills.jpg</a></td>

        		<td>28kb</td>

        	</tr> 
<tr>

        

        		<td><a href="C:/wamp/uploads/Symfony2-QuickTour.pdf">Symfony2-QuickTour.pdf</a></td>

        		<td>131kb</td>

        	</tr> 
<tr>

        

        		<td><a href="C:/wamp/uploads/Winter.jpg">Winter.jpg</a></td>

        		<td>103kb</td>

        	</tr> 
</table>

</body>

</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.