Click here to Skip to main content
16,021,125 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to download a file from a php page then save it into a folder, after that retrieve the saved file then send it to all user inside the database.
Posted
Updated 25-May-11 22:54pm
v2
Comments
Sandeep Mewara 26-May-11 4:54am    
Tried anything?
jiasing 26-May-11 5:07am    
yes, by putting the download and send coding in one php page the file can only be download but not sending to the user in database.

1 solution

From the standpoint of the client (download is always done by software playing the role of the client), there is no such thing as "PHP page". For a client, all pages are the same. HTTP is HTTP.

If you want do download anything with PHP, look here: http://php.net/manual/en/function.fopen.php[^]. There is a download sample on this page, please find it. Basically you simply open a stream and binds with any resource by its URL, depending on the URL scheme you use. This is transparent to the downloading code.

—SA
 
Share this answer
 
Comments
jiasing 26-May-11 21:13pm    
Hi, I can already download the file to the path i want. but the problem is how can I send it to the user automatically after download the download is done. If i separate both download and send into two button it works. thanks.
Sergey Alexandrovich Kryukov 28-May-11 2:45am    
I don't know exactly in what context you download the file.

If you download in the code of (another) web application, you should simply save is in the directory structure served by your HTTP service under some unique name, calculate its HTTP URL relative to some page and generate such page with Here is the file you requested!.

If you're doing something different, please explain.
--SA
jiasing 29-May-11 21:52pm    
thanks. The needs is i have to download the data(a list of weekly report) from my database into an excel file and save it into my disk. And after it had been downloaded, it will automatic send to the user.By the way, I had solve the problems. Thanks.
Sergey Alexandrovich Kryukov 30-May-11 13:37pm    
You're welcome.
Are you considering to formally accept my answer (green button)?
thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900