Help to create id for files!
Started on the old forum in August 2012 · view the original in the archive · old links redirect here
You will have to put records in a database or flatfile etc
A simple way to do that
Imagine u've got a table in a database with 3 coloums
ID | fileName | URL
1 | flower.jpg | /files/images/flower.jpg 2 | music.mp3| /files/music/music.mp3 3 | vido.mp4 | /files/videos/vido.mp4
Then make a custom php script ~ download.php
<?
if (isset($_GET['ID']))
{
mysql_connect("localhost", "root", "");
mysql_select_db("DATABASE");
$ID = (int) $_GET['ID'];
$sql = "SELECT URL FROM TABLE_NAME WHERE ID = $ID LIMIT 1";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 1)
{
$row = mysql_fetch_assoc($result);
//Redirect user to the file
$download_url = "http://example.com".$row['URL'];
header("Location: $download_url");
exit();
}
else
{
echo "Not found!";
}
}
?>
There are many more ways to do the same thing, its up to your creativity
I need some facebook likes, can you please help me 🤝 http://facebook.com/softwarefreakin I noticed social media is really powerful 🧙 Well DONE is better than well SAID
softwarefreak wrote: You will have to put records in a database or flatfile etc
A simple way to do that
Imagine u've got a table in a database with 3 coloums
ID | fileName | URL
1 | flower.jpg | /files/images/flower.jpg 2 | music.mp3| /files/music/music.mp3 3 | vido.mp4 | /files/videos/vido.mp4
Then make a custom php script ~ download.php
<? if (isset($_GET['ID'])) { mysql_connect("localhost", "root", ""); mysql_select_db("DATABASE"); $ID = (int) $_GET['ID']; $sql = "SELECT URL FROM TABLE_NAME WHERE ID = $ID LIMIT 1"; $result = mysql_query($sql); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); //Redirect user to the file $download_url = "http://example.com".$row['URL']; header("Location: $download_url"); exit(); } else { echo "Not found!"; } } ?>There are many more ways to do the same thing, its up to your creativity
Thanks bro for your support! can we use arrays instead of sql?