PDA

View Full Version : File path chooser



ezriel
3 Oct 2012, 8:00 AM
Hi,
I have rest client with extjs and i want to let the user choose where to save the file. The file is saved as a pdf on the client machine via java and itextpdf library. I have to send only file path to the client back-end . How to create 'save as' dialog to get only file path?
Here is the example what i need but written in java.
http://www.java2s.com/Code/Java/Swing-JFC/ChooseaFile.htm

(http://www.java2s.com/Code/Java/Swing-JFC/ChooseaFile.htm)There is xtype: filefield in extjs but it is used to choose existing file. I need to choose path to the new file.

scottmartin
3 Oct 2012, 6:28 PM
So after you call send the file from iText using shell_exec and use window.open to save the file on the client, you then want to send the file back to the server and specify the path?

Scott.

ezriel
4 Oct 2012, 12:11 AM
So after you call send the file from iText using shell_exec and use window.open to save the file on the client, you then want to send the file back to the server and specify the path?

Scott.

User has export button. When he presses it i want to show him window where he can choose where save the file. Then, extjs sends file path to the client rest controller. Controller gets needed data from server and save file via itext on client machine to the specific path.

scottmartin
5 Oct 2012, 5:17 AM
This is handled automatically by browser. I have the same setup ..

-Button to create PDF using iText (ajax)
-IText generates PDF, and call shell_exec($report_string); // java -jar ....
-Response sent back to client and window.open(report_name + '.pdf'); // open window to save

I think the difference is that you want to ask before, where the browser will see the file and ask after it returns.

Scott.

ezriel
6 Oct 2012, 2:46 AM
This is handled automatically by browser. I have the same setup ..

-Button to create PDF using iText (ajax)
-IText generates PDF, and call shell_exec($report_string); // java -jar ....
-Response sent back to client and window.open(report_name + '.pdf'); // open window to save

I think the difference is that you want to ask before, where the browser will see the file and ask after it returns.

Scott.

Yes, but i think your solution is better. Can you show me how can i use shell_exec to send back generated pdf file?

scottmartin
6 Oct 2012, 7:19 AM
I simply call the report with these parameters and it generates the report:

PHP backend:


$report_string = 'java -jar java/' . $reportName . '.jar "' . $reportOrder . '"' . ' "' . $reportOrder . '"' . ' "' . $reportFilter . '"';
$result = shell_exec($report_string);

if ($result) {
echo "{success:true}";
} else {
echo "{success:false}";
}


Scott