Hy,
Im having a bit problem and wondered if anyone could help me! Anyways, I ...
-
Automatic Filename Generator - Help Me?!
Hy,
Im having a bit problem and wondered if anyone could help me! Anyways, I have a website where I will let people download different files, but the file content is always the same. I think I could get higher conversion rate if i could change the file name according to the download link.
Example:
At the moment i have example "Download SongName1" when person clicks it, he gets a file download.rar
What I want is that when a person clicks "DOwnloads Songname!" then he would get the file SongName1.rar etc.
The reason why im asking this is, that i dont want to have 200-300K files on my server and link them to each download page 
Im pretty sure that there must be a possibility to autogenerate file names 
Thanks in advance!
-
-
-
Re: Automatic Filename Generator - Help Me?!
Help is still very much needed and I know that there must be a way to do it
but how...
-
-
Re: Automatic Filename Generator - Help Me?!
I could write you up a php script that copies the rar a bunch of times and renames it every time, though that would use up a ton of disk space, shoot me a PM, i'll help you out with this
-
-
Re: Automatic Filename Generator - Help Me?!
How big is the file your posting and how often is it being downloaded?
You can have a PHP script serve up the file to the client, claiming the file name is anything you want. (Though consumes PHP server resources really fast depending on how many concurrent downloads are happening.)
I'll see if I can throw together a quick demo...
PHP Code:
<?php
//Don't allow the script to timeout
set_time_limit(0);
//Get local file path
$file_path = "./randomfile.rar";
//Abort if the file does not exist
if (!file_exists($file_path))
{
echo "<h1><font color='red'>ERROR LOCATING FILE</font></h1>";
die;
}
//Get the file size from the file system (database for display only)
$file_size = filesize($file_path);
//The claimed filename (can be whatever you want... should match proper mime type.)
$claimed_filename = "smackthat.mp3";
//Claimed MIME type--reference list of mime types for different files names at: http://www.feedforall.com/mime-types.htm
$claimed_type = "audio/mpeg";
// Set transfer headers in browser
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: $claimed_type");
header("Content-Disposition: attachment; filename=\"$claimed_filename\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $file_size);
//Transfer the file via the script (impossible for user to see true location on server)
$file = @fopen($file_path,"rb"); //Open file in binary mode
if ($file)
{
while(!feof($file)) {
print(fread($file, 1024*8)); //Transfer in 8kb chunks
flush();
if (connection_status()!=0) { //What to do if client terminates connection
@fclose($file);
die();
}
}
@fclose($file); //Close the file at the end
}
?>
This is for some code I wrote earlier to protect the server location of files I was serving. (So people could not download them without being logged in + having proper credentials.) I modified it to suit your purpose--you modify the true file location, claimed type, and claimed name. You can have them based on whatever scripting information you want.
Also, if you don't really care about them downloading a valid file you could just send some random data and claim it's a file... (Would use significantly less server resources.)
Last edited by drkenneth; 02-25-2009 at 04:31 AM.
-
-
Re: Automatic Filename Generator - Help Me?!
thanks drkenneth
Well, the problem is that the file is just a packed text file which suggest you to fill out some offer and etc. Just for example...
But hmm, how much resource would it take and would it kill my connection? I mean there arent lots of downloads and I dont believe that there are any simultaneous downloads either.
PS - Could you explain your script a bit more, im just a bit stupid here :/...
File size is some 100kb or less 
Also - does anyone know how could I become an affiliate of such websites which allow people to download files when they pay for the sign up? Some Mp3 download sites and etc use it. Click here to download or Click Here to Download fast and it is somekind of affiliate link, but i have never searched it before and now I cant seem to locate one such website
-
-
Re: Automatic Filename Generator - Help Me?!
With a file of that size/traffic it would be fine. I just wanted to make sure it wasn't like a 10MB file downloaded every minute, haha.
The script's comment explain what each individual part does, but I'll give you a brief summary of the overall idea.
Basically, instead of simply linking the browser to a file on the server, you link them to a php script. This php script then opens the local file on your server, and then sends the browsers the proper headers the user would get if they were actually downloading a file of whatever type you want. The script then proceeds to read the file and output it to the web browser after the headers in 8kb chunks until it's complete or the user disconnects. Basically the identical process to them opening the file, except managed through the PHP script rather than the server only. This allows you to control the file name the browser believes they are downloading, the file type, etc.
Also, in the case of a zip file you would want the "application/zip" MIME type in the script. (So the browser knows how to handle it.) You can script the file name ($claimed_filename) to be whatever you want based on a get string argument, post string, random, etc. etc.
-
-
Re: Automatic Filename Generator - Help Me?!

Originally Posted by
eestisiin
Also - does anyone know how could I become an affiliate of such websites which allow people to download files when they pay for the sign up? Some Mp3 download sites and etc use it. Click here to download or Click Here to Download fast and it is somekind of affiliate link, but i have never searched it before and now I cant seem to locate one such website

Try searching for those SMS download gateway, I'm using one that is from Spain (sepomo.com) and your visitor send you a sms and receive the code to download the file.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks