Forum Moderators: coopster

Message Too Old, No Replies

Getting a filename from a "Save as" dialog input?

How to do so?

         

NooK

11:32 am on Sep 4, 2008 (gmt 0)

10+ Year Member



I am trying to dinamically create a CSV file out of a SQL database with php and save that to a csv file so the user can later open that file on Excel or similar.

The idea is to have a dropdown menu which lists all the database tables and an "Export" button which would open a "Save as" dialog where the user input the filename and path and upon clicking save the file is created.

My problem is that I cannot find a way to get that Save As dialog that will return the entire path the user has chosen and the filename to then submit it to the form to create the file.

<INPUT type="file"> does what what I need but it has a big text field attached to it which I dont want and also it doesn't seem to be possible to change the word "browse" from the button.

Has anybody got any ideas?

penders

11:58 am on Sep 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<INPUT type="file">

This is intended to upload a file from the local machine to the server, which I don't think you want to do.

I would have thought you'd need to generate and save the file entirely on the server (in fact you don't even need to save it) but then provide the file as a download (by sending the appropriate headers, or simply by providing a link if you have saved it). The user will then be presented with a standard download dialog, which should include the option to "save file" - this is your "Save As" dialog.

(You cannot save a file directly to the local machine using PHP as you seem to be implying? You need to present it as a download to the user. If you want to give the user the ability to "Save As..." the file somewhere on the server (careful with security) then you will need to create your own "Save As..." dialog as a regular HTML form.)

NooK

12:56 pm on Sep 12, 2008 (gmt 0)

10+ Year Member



Thanks I got it to work with headers. I completely forgot the fact that I cant obviously save the file in the users pc without the user manually doing so localy.