473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

generate a file on client host

Hi all,

I have a link on my web site that intends to support the user generate a csv file of a table. But I have a problem that it generates the file onto the server - which is not the intention. Please help me to create one.

The code I have is



Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT `Year of Data Entry` ".
  2.             "INTO OUTFILE '/tmp/files/myfile.csv' " . 
  3.             "FIELDS TERMINATED BY ',' " .
  4.             "ENCLOSED BY '\"' " .
  5.             "LINES TERMINATED BY '\n'    " .
  6.             "FROM table1";
  7.  
  8. $result = mysql_query($query) or die(mysql_error());
  9.  
  10.  
  11.  
  12. Thanks in Advance
  13.  
  14.  
Mar 13 '09 #1
1 1128
Atli
5,058 Expert 4TB
Hi.

You have no actual access to your client's hard drive, so your code can not actually put files directly onto your client's computer.

What you can do is have the server send the file to the client and have them download it.

For example, you could put this at the bottom of the code you posted:
Expand|Select|Wrap|Line Numbers
  1. header('content-type: text/csv');
  2. header('content-disposition: attachment; filename=table.csv');
  3. readfile('/tmp/files/myfile.csv');
  4.  
Which should have your client's browser open a "Save As" dialog.
Mar 14 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via...
3
by: ferbar | last post by:
Hello all, This may sound pretty basic stuff.. but I'm working on a socket example whose client seems to work fine, but the server doesn't send to the client the expected result. The problem is...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
8
by: Phil Lee | last post by:
I'm sure this is possible but I just can't see how to do it. I want to add schemas to my solution and have C# classes automatically generated from them. I can see how to generate typed DataSet's...
2
by: Delmar | last post by:
I need to build Web Application that will generate a client to execute some operations. Each client has running silent application. Maybe somebody can advice me what can I do ? Thank you.
6
by: Martin A. Weinberger | last post by:
Hi All, Using JavaScript, how do I download a file to a user's computer that I have stored on the server in a relatively browser indepdent way? That is will work on Mozilla and Macintosh Safari...
4
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command...
0
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hello, friends, I am creating duplex WCF service with the following configuration: <system.serviceModel> <services> <service behaviorConfiguration="MetaEnabledBehavior"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.