Need some ideas

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Need some ideas

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post 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)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Store it in a blob field.
Also check How to Store Images Directly in the Sql Database - same method.
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post 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
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

Right right, but how do I make PHP know when to delete the copied file is my main concern.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post 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*
Last edited by Bigun on Tue Jun 27, 2006 2:28 pm, edited 1 time in total.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post 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...
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post 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...
Bigun
Forum Contributor
Posts: 237
Joined: Tue Jun 13, 2006 10:50 am

Post by Bigun »

If I get that much activity, I'll be happy to rethink it.
Post Reply