March 25, 2019, 02:56:19 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
   Home   Help Search Login Register  
Pages: [1]
Author Topic: file smart download script for random file names  (Read 4089 times)
Posts: 3

« on: July 23, 2009, 02:06:20 AM »

I will explain myself:

I have created table in MySQL called it “files” that contains names of the original files on my server and the random names assigned to each of this files: (Not sure if this is a right way)

001Purchase-Order-Template.xls file-purchaseorder

all original files are in the folder called /files/ on my server.

I have also used some PHP script to enable users to download each file and named it download.php

This is the script that I have used: (again not sure because I do not know much about PHP)

// Connects to your Database
mysql_connect("serveraddress", "username", "password") or die(mysql_error());
mysql_select_db("username") or die(mysql_error());
$data = mysql_query("SELECT * FROM files")
or die(mysql_error());
//get the original file name
//where your $_GET['urlid'] =
//RandomFileName and set it equal
//to $saveName

//this will be equal to the
//original file name you get from
//the db
$saveName = "OriginalFileName";

$fileName = $_GET['urlid'];
Header("Content-type: application/xls");
Header("Content-Disposition: attachment; filename=$saveName");


Now when I am placing a simple link on the page were user can download the file from in this format:

Download Now

when you click on the Download Now link the process starts running but you cannot get the actual file at the end for some reason.

I think I do have an error some ware in the script but cannot figure it out. could anyone please help me a little and could you actually use the names that I have provided so I can see what goes were?

Thanks in advance

Pages: [1]
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC