0

Hi everyone

I have over 1500 mp3 files that are available for download on a web site I look after. The files are various sizes and split between 20 folders. One folder has about 600 files.

What the owner would like for his visitors is to be able to select a number of these files, and the click on a Download button. The selected files would then be downloaded to a visitor nominated folder on his/her PC, with no further intervention by the visitor.

Does anyone know how this might be done using PHP and perhaps JavaScript?

Thanks
Terry

6
Contributors
19
Replies
23
Views
6 Years
Discussion Span
Last Post by cooperspc
Featured Replies
  • 1
    diafol 3,669   6 Years Ago

    Anybody who'd want to download hundreds of raw files must be bonkers! Are zip files for advanced users only?? AFAIK, a dialog pops up from the browser on each download file - as security. You can't make 'silent' downloads. That would open the user up to all sorts of nasties. … Read More

  • 1
    diafol 3,669   6 Years Ago

    Yes, the fact that you're running a testing server on the local machine and can save files to its directories via cURL isn't the same as an user downloading files to his/her computer from your site. As for WAMP - it's just one of a number of packages. I use … Read More

0

It would probably be easiest to zip or otherwise compress the files to be downloaded, and then have the visitor extract the files from the downloaded archive. Otherwise, the visitor will have to specify a download location for each mp3 file, which could be very annoying depending on how many files they have selected for download.

Check out Zend tutorials for making a compressed file on the fly. A good article can be found here: http://devzone.zend.com/article/2105

Let us know if you need any more help on getting started, and good luck!

-Ty

0

Hi there Yy

I forgot to mention that zipping the files isn't an option as the users who will most often use this service are generally computer illiterate, unfortunately.

I'm also just started looking into using Curl, so that could be added to my initial enquiry.

Thanks again
Terry

1

Anybody who'd want to download hundreds of raw files must be bonkers! Are zip files for advanced users only?? AFAIK, a dialog pops up from the browser on each download file - as security. You can't make 'silent' downloads. That would open the user up to all sorts of nasties.

Archive is the best way - seriously.

Edited by diafol: n/a

1

There is nothing php related that can just push files to a user's computer without the user's interaction. The same goes for anything built around javascript and php.

The user would need some kind of client on their pc that could interact with your server and handle the transfer.

0

Anybody who'd want to download hundreds of raw files must be bonkers! Are zip files for advanced users only?? AFAIK, a dialog pops up from the browser on each download file - as security. You can't make 'silent' downloads. That would open the user up to all sorts of nasties.

Archive is the best way - seriously.

Agreed. 'Silent' downloads would be a huge security concern as any old spam-filled website would be able to put whatever they wanted onto their visitors' computers.

Maybe TAR, RAR, and other archives would be too unfamiliar for the average user, but a plain old zip file? I would trust most users to be able to figure out a zip. If you really think your average users wouldn't be savvy enough to unzip a file, downloading each file individually is the only way. Maybe you could include instructions on "How to Unzip a File"?

0

Hi again

Thanks to everyone for your replies, except I would just like to mention to Ardav that the files in question are not RAW files but MP3s.

As I have mentioned earlier, it seems that curl might be the way to go, and the server my client uses supports it, so a bit of testing with curl will be the order of the day for a while.

I'll leave the thread open for a few more days, just in case?

Thanks again
Terry

Edited by terrymold: n/a

0

I think Ardav just meant that it would be silly for a user to want to manually download tons of files of any kind over and over again (not to speak for Ardav, of course, but that was my impression) when it would be simpler to download a single zip that could contain all of those files.

I'm not too familiar with curl- what do you hope to do with it to enable the download of multiple files (just out of curiosity). If you do find a way, let us know! I'd be interested to know of an alternative solution.

0

Thanks TySkby. I was refering to the idea of downloading numerous raw files (any type of file in their native format) as time-consuming - I didn't put it very well. I was intrigued by the idea, so I did a cursory search, but all the posts seemed to confirm my feelings that security is the stumbling block for multiple native file download.

I thought of self-extracting archive (*.exe), which would obviate the need to use an extractor (e.g. Winzip, 7-Zip etc.). I couldn't find a php script for this. PHP has a number of functions to create zip, gzip, rar etc, but no exe archives.

I have to be honest, even an exe file would make me think twice. A malicious exe file could totally mess up a user's HDD. So, I stick by my first post - download a zip file.

I think TySkby's idea of 'How to extract mp3s from a zip file' is the way to go.

I know it's frustrating, but these security measures are there for a good reason. You can bet if there was a way to circumvent these, the next versions of browsers would plug the hole or at least patches for current browsers would be released.

0

Thanks TySkby and ardav

I suppose that's a new way to describe native files?

Anyway, I know virtually nothing about cURL but at first look it can't be that hard to learn. Especially when I started with ZX81 basic, then CP/M, then Forth and so up through all versions of DOS.

This is the initial statement from my client's host regarding cURL.

cURL is a useful tool designed for sending or receiving files using URL's rather than traditional file extensions. It is available on Linux servers.

And I certainly will do my best to remember to let you know how I get on with cURL. So keep your eyes on this post.

Regards
Terry

0

> cURL is a useful tool designed for sending or receiving files using URL's rather than traditional file extensions. It is available on Linux servers.

I assume this is referring to transfer between your site and other sites not to a download on a local machine.

0

Hi ardav

As far as I can tell, you can tell it to download the URL or file anywhere, including a local HD.

I use Wamp to do all my testing etc, and you can download a version for win32 or 64 to run locally as well.

But what is even more amazing, it seems to have been around for about 10 years already? And I'd never heard of it until the other day.

There are plenty of googles that will explain everything, and some sites with too much info.

Regards
Terry

1

Yes, the fact that you're running a testing server on the local machine and can save files to its directories via cURL isn't the same as an user downloading files to his/her computer from your site.

As for WAMP - it's just one of a number of packages. I use XAMPP myself, but they all do pretty much the same thing. Apache/MySQL/php.

> There are plenty of googles that will explain everything, and some sites with too much info.

To what is this referring? Downloading files to a user's computer via cURL??

0

Hi everyone

I have over 1500 mp3 files that are available for download on a web site I look after. The files are various sizes and split between 20 folders. One folder has about 600 files.

What the owner would like for his visitors is to be able to select a number of these files, and the click on a Download button. The selected files would then be downloaded to a visitor nominated folder on his/her PC, with no further intervention by the visitor.

Does anyone know how this might be done using PHP and perhaps JavaScript?

Thanks
Terry

It very fast and easy to get the things whatever we wants

0

I only use Wamp for testing before uploading scripts to my client's server.

My reference to google meant exactly that. Do a google on cURL.

The fact that I'm using Wamp has no bearing at all to cURL.

And as far as I'm aware, by reading stuff on Google about cURL, you CAN download files to your local PC's Hard Disk. But it doesn't do it by Filename, but by URL, hence the name cURL.

Terry

0

> The fact that I'm using Wamp has no bearing at all to cURL.
So why mention it? I got confused :~

> My reference to google meant exactly that. Do a google on cURL.
Yes, I know a little about cURL, having used it successfully in a number of projects.

> And as far as I'm aware, by reading stuff on Google about cURL, you CAN download files to your local PC's Hard Disk. But it doesn't do it by Filename, but by URL, hence the name cURL.

I think you should read the php manual on cURL. http://php.net/manual/en/book.curl.php

So what you're saying is that if I select a bunch of mp3s to download, your site is going to write a stack of links somewhere on my machine? You sure about that?

Anyway, I said my piece, it's your time. Frankly, I'd trust my users to unzip a file before trying to force a silent download on them.

Good luck with it though.

Edited by diafol: n/a

0

I've looked into cURL a bit since yesterday...

This is a basic example, but if I cURL this in command line or via some server-side script:

curl -o this_thread.html http://www.daniweb.com/forums/thread339219-2.html

I would get the HTML of page 2 of this thread saved to my local machine as this_thread.html

So from my understanding, you can use cURL to grab content from the web and save it to your machine, and it seems to be mainly a tool for scraping content of a file (remote or local) and saving that somewhere local.

So, your server can cURL information from wherever you please, but in the end, you will still have a file on your server that you will need to figure out how to allow the user to save.

The only way I could see cURL being a solution to your problem is if your site's visitors used cURL installed on their machines and ran a command or a script that would scrape your site's server for the mp3s they selected and save them locally.

So what you would have to do then is this:
1. Have the users select the mp3s and specify a directory on their computer.
2. Your server creates a script that includes your mp3s' URLs and a corresponding file name for the mp3s, set up to download to their specified directory.
3. The file they downloaded via their browser would be the (batch) script from step 2 4. The user runs the downloaded script that would contain the necessary cURL queries, and once the script was complete, they would theoretically have the mp3s transferred from your site to their local machine.

BUT that would assume that every user would have cURL installed on their machine, as well as knowing what to do with their custom-generated batch file once they had downloaded it from the browser.

Personally, I would think that would expect wayyyy too much for the average computer-illiterate user, especially when you consider that the command line tends to scare the average Joe. I would be concerned if I thought I was downloading mp3s and ended up with a file that whizzed through my command-prompt, even if it did successfully download the mp3s in the end.

To put it succinctly, the reason I think cURL won't work for this problem is that you use cURL for this:

(Remote file) -> (URL pointing to remote file) -> (Your local machine running cURL)

and not for this:

(Your server running cURL) -> (URL pointing to your server's file) -> (Remote user's machine)

In a nutshell: cURL is for pulling, not for pushing.


NOTE: Please understand, as far as I'm concerned, you can try to do what you're doing using cURL. Maybe I'm way off-base with this one (I don't think so though), but I just wanted to share my thoughts after doing a bit of digging. All things considered, I think you'd have better luck with a Zip and some instructions if necessary, but by no means am I suggesting that trying and experimenting are a waste of time.

0

There is nothing php related that can just push files to a user's computer without the user's interaction. The same goes for anything built around javascript and php.

The user would need some kind of client on their pc that could interact with your server and handle the transfer.

TySkby I agree, that was the same conclusion I arrived at 12 posts ago. Although cURL is really designed for pulling and pushing, just not to a remote users computer. cURL is a very valuable tool to developers for interacting with a whole variety of protocols including ftp, scp etc. Which would be bi-directional communication.

Now we wait and see if the OP arrives at the same conclusion. You can lead a horse to water but you can't make him drink.

Edited by mschroeder: n/a

0

@ms & Ty

Not to disparage the OP, but I don't think he quite gets the difference between a remote site and a remote user. Nuff sed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.