thenewprogrammer
New Member
- Messages
- 45
- Reaction score
- 0
- Points
- 0
Trying to do something like rapidshare but on a loss for how to do it. Right now i have download page that makes links for all the users files they uploaded. But what i want to do is have the file on a download page like rapidshare which has custom download page when i go to the link instead of downloading it directly when i type the link in.
example of what i want to do:
http://rapidshare.com/files/315820206/crash.jpg.html
download.php
example of what i want to do:
http://rapidshare.com/files/315820206/crash.jpg.html
download.php
Code:
user = $session->username;
$sql = "SELECT * FROM users WHERE username='$user'";
$result= mysql_query($sql);
$row= mysql_fetch_row($result);
$path0= "../uploads/users/files/fi/";
$path1 = $row[6];
$path2 = $path0 . $path1;
// open this directory
$myDirectory = opendir($path2);
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<TR><TD><a href=\"$path2/$dirArray[$index]\">$dirArray[$index]</a></td>");
print("<td>");
$ext = pathinfo($dirArray[$index], PATHINFO_EXTENSION); // When you set an option, the function returns a string
if ($ext === 'jpg') {
echo "jpg";
} else if ($ext === 'png') {
echo "png";
} else if ($ext === 'gif') {
echo "gif";
} else if ($ext === 'php') {
echo "php";
} else if ($ext === 'zip') {
echo "zip";
} else {
return false;
}
print("</td>");
print("<td>");
print(filesize($path2."/".$dirArray[$index].''));
print("</td>");
print("</TR>\n");
}
}
print("</TABLE>\n");
Last edited: