PDA

View Full Version : about downloading image from remote server


mallesh
11-21-2003, 03:13 AM
Hi Antun,




In our appln, we are allowing the user to upload their own images.For this, i am calling JSP file by clicking on the button "upload image", from lzx file.that JSP file will allow the user to select an image and call another JSP.This latter JSP file is taking care of storing the image to an remote server,And also it creating one XML file for storing the name of the uploaded image.Once the image has been uploaded,i am downloading that image from the remote server by sending the HTTP request to that XML file from same LZX file .For that I am using another Button "ADD IMAGE" (here i am calling doRequest()method).

Here, is it possible to use only single button like "upload image" for both the action?. I mean i don't want to use "ADD IMAGE" for downloading and displaying it in my appln.The whole thing should happen in one action(like, by clicking on the "upload image ").

<dataset name="dset1" src="http://localhost:8080/upload/jsp/uploadimage.xml" autorequest="false" type="http"/>

<view x="30" y="40" id="upload" resource="Images/upload.gif" clickable="true" onclick=" postpage">
<method name="postpage" event="onclick">
LzBrowser.loadURL('http://localhost:8080/upload/jsp/upload1.jsp', '_blank');
</method>
</view>
<view x="36" y="130" id="add" opacity="0.4" resource="Images/add.gif" >
<method event="onclick">
loadingIndicator.setVisible( true );
var d = canvas.datasets.dset1;
d.doRequest();
</method>
</view>
<view name="upload" x="140" y="150" width="120" height="120" datapath="dset1:/upload/FileName/text()">
<method name="applyData" args="d">
setSource( "http://localhost:8080/upload/uploadedfiles/" +d);
</method>


Thanks alot
Mallesh

antun
11-21-2003, 08:55 AM
Hi Mallesh

I think I understand what you're asking. Yes I believe it is possible:

Once you have opened the window with the download form (i.e. called postpage()), start polling a JSP on your server with requests at regular time intervals, from the Laszlo app, that checks to see if the upload is complete. You could also use this to let the user know that something is happening by displaying some kind of upload notification in the Laszlo app.

The Laszlo app will know that the upload is finished and that it's time to request the image, because a request will come back and let it know.

You would need to have some kind of unique identifier that both the Laszlo app and the JSP were aware of. You could generate the unique identifier in the Laszlo app, and pass it as a CGI GET variable when you call LzBrowser.loadURL().

Take care,

Antun