Real Software Forums
http://forums.realsoftware.com/

create file and download - Web Edition
http://forums.realsoftware.com/viewtopic.php?f=23&t=47690
Page 1 of 1

Author:  shahiddarbar [ Wed Apr 24, 2013 9:26 am ]
Post subject:  create file and download - Web Edition

Hi,

To create a text file in a variable (webfile).

To ask the download location (with SaveAs dialog - yes in web edition)

Save the file on client.

All these in Web Edition.

Thanks,

Author:  Akiland [ Wed Apr 24, 2013 9:43 am ]
Post subject:  Re: create file and download - Web Edition

shahiddarbar wrote:
Hi,
To create a text file in a variable (webfile).
To ask the download location (with SaveAs dialog - yes in web edition)
Save the file on client.
All these in Web Edition.
Thanks,


Simply put your textfile in a WebFile and present it to the client.
Pseudo code.
yourWebFile = WebFile.Open(f) '<--Folderitem to your textfile.
yourWebFile.MIMEtype = "text/plain"
yourWebFile.ForceDownload = True
ShowURL YourWebFile.URL


Remember to put "yourWebFile" in the Session or it might die too soon.

Where the file will be saved on the clients computer depends on their browser settings :)

Author:  shahiddarbar [ Wed Apr 24, 2013 9:50 am ]
Post subject:  Re: create file and download - Web Edition

can we get a saveas dialog so they can select where to save?

also, there is no physical file on server, the new file has to be created on fly

is this possible?

Author:  shahiddarbar [ Wed Apr 24, 2013 10:29 am ]
Post subject:  Re: create file and download - Web Edition

ok,

I am getting saveas box (not saveas dialog) on atleast opera and IE, safari and chrome save to default download location.



Is there a way to create a text webfile in code?


thanks,

Author:  Akiland [ Wed Apr 24, 2013 12:54 pm ]
Post subject:  Re: create file and download - Web Edition

If you don't have a file on the server, see WebFile.Data
You can't decide where the client will save the file. It's all in the control of "the client".
Personally I've set my browser to automatically download all downloadable files into a predefined directory so I never see the SaveAs Dialog. This setting can't be forced :)

Author:  vcetina [ Mon May 06, 2013 8:51 pm ]
Post subject:  Re: create file and download - Web Edition

Im trying to open a pdf file following the instructions you kindly gave us, but i get nil object exception when the execution gets to the line
Session.pdffile.ForceDownload=True

here is my code
dim f as folderItem
f = GetFolderItem("../"+Session.usuario+"-report.pdf")
Session.pdfFile = New WebFile
Session.pdffile = WebFile.Open(f)

Session.pdffile.ForceDownload=True
Session.pdffile.MIMEType= "application/pdf"
ShowURL(Session.pdffile.URL)

Help please.
TIA

Author:  Akiland [ Tue May 07, 2013 12:56 am ]
Post subject:  Re: create file and download - Web Edition

vcetina wrote:
Im trying to open a pdf file following the instructions you kindly gave us, but i get nil object exception when the execution gets to the line
Session.pdffile.ForceDownload=True

here is my code
dim f as folderItem
f = GetFolderItem("../"+Session.usuario+"-report.pdf")
Session.pdfFile = New WebFile
Session.pdffile = WebFile.Open(f)

Session.pdffile.ForceDownload=True
Session.pdffile.MIMEType= "application/pdf"
ShowURL(Session.pdffile.URL)

Help please.
TIA


Are you sure it's on that line and not the one above? (Session.pdffile = WebFile.Open(f))
Your FolderItem don't look right to me, it might not find the file and therefor give you an error on WebFile.Open(f).

Author:  vcetina [ Wed May 08, 2013 11:26 am ]
Post subject:  Re: create file and download - Web Edition

Thanks for the advice Akiland. Problem solved, the file path was wrong.

Now im trying to create a HTML file with a predefined string, with the path to the pdf (to display the html in a separate window using javascrip window.open). But when asigning the string with the returned hml in this way
session.fHTML.data=createHTML(session.pdf.url)

im getting NIL OBJECT EXEPTION. The error is generated in this line, not in the createHTML function.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/