Download File

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
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Download File

Post by Clukey »

Is it possible to have a user download a file onto their computer, then when when the download has completed update a database? I know how to update the database, but how can I do the rest? Thanks
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Consider using

Post by akimm »

Javascript or Html to mitigate the download. I'm sure php has a way but I'm way too new to demonstrate that for you.
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

How could I do that with html and then call a php function to update the record?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Look at PHP's header() function for information about downloads. You would update the database in the script as you normally would. However, once you generate the download response for the client/user, you cannot know what they did with the file.
(#10850)
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

I tried using header() but I am getting this Error

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/folder1/folder2/page.php:35) in /home/folder1/folder2/page.php on line 40
Are there any workarounds? Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

Thanks for that, I didn't need that echo anyway, but now it's giving me an error that says I am unauthorized to view that page. I do have hotlink protection enabled, but I have accesses set up for my domain and it's not giving me errors on any of the other file types, just this one. And this is the only one I access with php. Any suggestions?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I'm really not clear what you are talking about. What echo? What do "hotlink protection enabled" or "have accesses set up for my domain" mean? And when you say "other file types" do you mean differnt files or differnt MIME types set in the header?
(#10850)
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

I had an echo "blablabla"; at the top of my page which screwed up the header(). Hotlink protection disalowes people from accesing files on my server. When I say other file types I mean the hotlink protection is only set up for certain file extensions (jpg,bmp,mxp,ect...) and they all seemed to be working, but none of the other types are called by php.

I did find a fix for this however. I found this post on php.net:

http://us3.php.net/manual/en/function.header.php#65667

Thanks for all your help.
Post Reply