Page 1 of 1
Need some ideas
Posted: Tue Jun 27, 2006 1:04 pm
by Bigun
I need some brainstorming here...
I've created something that will allow uploading of MP3's and the MP3's save as the default name that php randomizes. I want downloading of these MP3's to only be available to users who have registered.
Now, here's the thing. I can code the verification of the username, blah blah blah, but *how* do I make a dynamic file location for downloading and then be able to remove that file after it is finished downloading.
Posted: Tue Jun 27, 2006 1:46 pm
by anjanesh
You can have the mp3 stored in a database instead and stream the mp3 from the database directly - will incur more bandwidth and time.
Posted: Tue Jun 27, 2006 1:57 pm
by Bigun
How can you store a whole file into a database?
(On another note, I demand the developer tag be taken off my account, I'm nowhere near ready)
Posted: Tue Jun 27, 2006 2:02 pm
by anjanesh
Store it in a blob field.
Also check
How to Store Images Directly in the Sql Database - same method.
Posted: Tue Jun 27, 2006 2:06 pm
by aerodromoi
anjanesh wrote:You can have the mp3 stored in a database instead and stream the mp3 from the database directly - will incur more bandwidth and time.
You don't have to use a database just to make sure that only registered users can download a file.
Just put a htaccess file in the dir holding your mp3s (FilesMatch) which denies direct access to the mp3s.
You can then use a php script to output the mp3s (using readfile).
aerodromoi
Posted: Tue Jun 27, 2006 2:11 pm
by Bigun
Right right, but how do I make PHP know when to delete the copied file is my main concern.
Posted: Tue Jun 27, 2006 2:17 pm
by anjanesh
No deleting - access to that folder is given to restricted users based on the list in a htaccess file.
I think you're talking abt the method like
webshots - download the file from a particular location and once its downloaded, the link is invalid.
You can create a session for this, create a folder with the sessionname as the foldername, copy the mp3 from the original source to this temporary sesion folder and somehow track the progress of the upload from the server's end. Once all the bytes are sent, delete the folder.
Posted: Tue Jun 27, 2006 2:24 pm
by Bigun
anjanesh wrote:I think you're talking abt the method like
webshots - download the file from a particular location and once its downloaded, the link is invalid.
You can create a session for this, create a folder with the sessionname as the foldername, copy the mp3 from the original source to this temporary sesion folder and somehow track the progress of the upload from the server's end. Once all the bytes are sent, delete the folder.
Yes, that's more what I am looking for. Any webpages that can relay more info about this?
*edited for typo*
Posted: Tue Jun 27, 2006 2:28 pm
by anjanesh
Posted: Tue Jun 27, 2006 2:36 pm
by Bigun
anjanesh wrote:and somehow track the progress of the upload from the server's end. Once all the bytes are sent, delete the folder.
I don't believe sessions handle this...
Posted: Tue Jun 27, 2006 2:46 pm
by aerodromoi
There's one drawback to your idea using a script that copies a particular mp3 into a "one-way" directory:
Just imagine x people trying to download y mp3 files each.
Irrespective of your cpu ressources, you'd definitely have to have a bit of extra webspace...
Posted: Tue Jun 27, 2006 2:54 pm
by Bigun
If I get that much activity, I'll be happy to rethink it.