Solved

How to download csv files from server

Posted on 2014-10-29
10
186 Views
Last Modified: 2014-11-28
Hi, I am using cakephp and I have created a few excel csv files stored on a server.
I want to be able to press a button on one of the webpages and download the whole folder of csv files from the server to my PC. How do I do this in php?
0
Comment
Question by:jagguy
10 Comments
 
LVL 1

Expert Comment

by:gireeshbabu
ID: 40410707
I would suggest to make a zip of all the server folder with files and give a download.
0
 
LVL 19

Expert Comment

by:Montoya
ID: 40411281
You can run a script server side, that zips all your files, or adds the latest file to the zipped file,
from there all you need is a link on the other end to initiate a download. No code needed (except for the script to start the zip process). Do you need help with that?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40411503
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:jagguy
ID: 40412036
yes i need help with the code please
0
 

Author Comment

by:jagguy
ID: 40412068
is there a way to do it without zipping the files?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 40412080
press a button on one of the webpages and download the whole folder of csv files
I don't think you can do it in a single click unless you can make references to all of the files at once, and that's where Zip comes into play.  You might be able to set something up with an FTP client on your local machine, but it will not be something that can be triggered with a mouse click on the web page.  It's a security thing.  Imagine if a web site could download files to your machine without your explicit permission.  You don't want to go there!
0
 

Author Comment

by:jagguy
ID: 40414995
Either way unless i find code to do this I am just talking about without getting anything done.  I dont mind being pointed to a website provided it has complete code and not snippets.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40424631
What part of "It's a security thing.  Imagine if a web site could download files to your machine without your explicit permission." do you not understand.  You are not going to find the code you are looking for because it would be necessary to bypass security to do it.  

You might find something on the darknet, but if you use it your site will very quickly be marked as dangerous by virtually every Anti-virus vendor on the planet. Plus a host that discovered it or got complaints about it would suspend your account to avoid liability.

Even if the server has no public access you probably will find that you are not likely to find a security admin in there right mind that would allow there servers to be used for such an operation.

Cd&
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
ID: 40425090
Cd& / Ray,

Not sure there is a security issue if jagguy owns the server?  The browser will of course have to handle the download.  You will of course not be able to bypass that.

jagguy,

It can ONLY be done with one file at a time, hence the ZIP suggestion.

As was stated before, you can only send one file at a time back to the client, which is why a zip file was suggested as you can zip up all the excel files in that folder and send that ONE file to the client.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question