Jump to content


Photo

How can I?


  • Please log in to reply
7 replies to this topic

#1 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 09 October 2006 - 08:12 PM

I don't want to upload files I want to allow people to choose a file and then to download it, how can I do this with PHP?

#2 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 09 October 2006 - 08:19 PM

Make a link to it in your html:
<a href="http://www.yoursite.com/file/path/filename.ext">Download this file</a>

I know that's not the answer you're looking for, but your question was rather vague.  Why don't you be a little more specific about how you're deciding what files to offer for download or some source code.

It's like joining an automobile enthusiasts forum and saying, "How do I build a car?"  Well, lots of ways.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#3 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 09 October 2006 - 08:23 PM

Ok, thanks I will try this idea:).
I thought it has something to do with $_FILE.

#4 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 09 October 2006 - 08:44 PM

Well, for example I have an archive and when you hit a link I want the browser to display where on my computer I want to download that archive (c:\ or d:\ etc) - maybe even to be able to create a folder on the remote machine where to copy that archive...
I hope that this information is sufficient...


#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 09 October 2006 - 09:43 PM

maybe even to be able to create a folder on the remote machine where to copy that archive


You cannot do ANYTHING on the client with php except create cookies.

#6 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 09 October 2006 - 09:50 PM

The functionality of creating folders on the client machine is usually available through the Save dialog box anyways.

Creating a link to download a file is as simple as creating the
<a href></a>
that I gave you above.  If there's multiple items you want to offer for download, you have to create a bunch of those links, one for each item.

The thing that differs is how you build the list.  If you have 100 files you want to offer for download, you certainly don't want to type that out 100 times.  And you certainly want it to stay up to date with which archives are actually valid and available for download.

We can help you do that, but not without you being more specific about where these files are stored, how your website "knows" about them, etc.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#7 amalosoul

amalosoul
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 12 October 2006 - 03:05 PM

Well, I have tried using a href but all it does is to open the file:).
I have a text document http://myhost.com/location/file.txt
and when I write <a href="http://myhost.com/lo....txt">Click</a> it simply opens that text file
it does not try to download it to the remote machine...
Thank you roopurt18 for your pacience, and thorpe for providing me that useful piece of information (I think I will start learnig Java to compensate for these things)...

#8 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 13 October 2006 - 05:46 AM

It doesn't try to download it because .txt files are easily opened within the browser.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users