PDA

View Full Version : Newbie Questions


jhambley@mac.co
03-30-2004, 12:31 PM
I'm just starting with the developer download and have some general questions.

1. Can a Laszlo application be used to allow a user to upload file(s) from their local machines to the server?

2. Does the application allow for downloads to the local machine?

We want to build a user-friendly interface for authenticated users to upload and manage a variety of resources (pdf, video, audio, flash) on the server.

Thanks in advance.

antun
03-30-2004, 12:59 PM
You can't upload an image from the Flash player directly (that's a limitation of the player unfortunately), but there are ways around that, that people have managed to do. The best way would be to pop up a new HTML window and have that window handle the upload.

See here:

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=366

Once the window was popped up, you could have the Laszlo app poll the server every few seconds to see if the upload had completed, and indicate it to the user that way.

As for downloading, you could use the LzBrowser service:


<canvas>
<window width="300" height="350">
<button>Download text.xls file now!
<method event="onclick">
LzBrowser.loadURL( "test.xls" );
</method>
</button>

</window>
</canvas>


... which will download a local file. I'm not 100% sure if that might cause problems. You see, LzBrowser.loadURL() is used for navigating to a page. The thing with browsers is that they will try to initiate a download if they hit an unrecognized MIME type (e.g. an Excel spreadsheet), and will cause the browser to start downloading the file instead of navigating to it. The app should still function fine in the browser window.

-Antun

-Antun

jhambley@mac.co
03-30-2004, 01:08 PM
I'll try your suggestions. Thanks again for your quick response!

vfunshteyn
03-31-2004, 11:28 AM
You may want to supply a second argument to loadUrl(), which is the name of the frame to start the download in. Otherwise, if your browser is able to handle the file's MIME type automatically, it will just open the URL in the same frame, navigating away from the app. This will be the case, for instance, with any error messages returned by the server, such as 404.

jhambley@mac.co
03-31-2004, 12:28 PM
Thanks so much for your suggestion!

jek
04-13-2006, 08:21 AM
Originally posted by antun
You see, LzBrowser.loadURL() is used for navigating to a page. The thing with browsers is that they will try to initiate a download if they hit an unrecognized MIME type (e.g. an Excel spreadsheet), and will cause the browser to start downloading the file instead of navigating to it.

-Antun

[/B]

Is there any way to force the download, even if the browser recognizes the mime type? I want to give the user a way to download pictures and songs by clicking on a link within my app, but I don't want the browser to start playing the song or show the pic within the popped up browser...

Thanks

maritimesource
04-22-2006, 06:49 AM
Originally posted by jek


Is there any way to force the download, even if the browser recognizes the mime type? I want to give the user a way to download pictures and songs by clicking on a link within my app, but I don't want the browser to start playing the song or show the pic within the popped up browser...

Thanks

This is more of a serverside scripting issue. Something like this, in php, would work:

$filename = $_REQUEST['file'];

header('Content-type: application/octet-stream');
header("Content-Disposition: attachment; filename=$filename");
readfile($filename);