Open/Save file from web client

Hi all,

What should I do, if I want to open a (save/open)FileDialog in WebClient just like same as rich client. If it is a media field, then it will shows the option to open the file dialog. If I am explicitly want to show a file dialog, such as on clicking of a button, then what should I do??

saveFileDialog() will let the user to save the file on the client’s system.

Thanks in advance.

to save a file (open a file save dialog) you just have to stream something (clicking on a link) to the browser then the browser will popup that
You cant ask for that to happen without that stream

to load a file this is also not possible by just an button you have to use the the input type = file for that else a browser wont allow you to do that.

I still have not been able to get the above to work while using with a global and with show URL. I just need to save a file to a global field and then open it using a URL. Does anyone have example code showing how this can be done?

Dean Westover
Choices Software, Inc.

the global is a media field?

then if you display it as a Media field then a user can upload a file (or save a file)
then i guess if you want to do something with it you can store it somewhere on the server and generate an url to it

(you have to store it in webapps\root dir)

Johan,

Can you make it for us much more easier. It looks we all have the same problem, but I haven’t seen a simple solution.
If I can remember well, I’ve seen in the past replies on the forum that upload/download files from the server when using webclient will be made much more easier, but it looks it hasn’t been realized yet.
More and more we want webclient solutions, but uploading a file to the server using a webclient still remains a problem.

Also for the download the solutions I’ve seen can work but I don’t see the perfect solution. When using the blobloader, you immediately have the data in the client and that doesn’t seem good solution as well. And using a .jsp page together with a headless client is not an easy solution as well.

Can you create some method which looks like the following:

boolean uploadFile(, || )

Otherwise perhaps you can restyle the svyDoc sample solution so that it also works in webclient. Then everyone can see how you guys at Servoy handle such a problem.

Martin

Johan,

In the support system I see a pop-up window for browse and upload:

<form id="id9c" method="post" action="?x=nijmbISW*CiLQnSZCRnMstunwCVTjjZ7" enctype="multipart/form-data"><div style="display:none"><input type="hidden" name="id9c_hf_0" id="id9c_hf_0" /></div>
<fieldset>
<legend>Upload form</legend>
<p>
<label for="upload">File</label>
<input id="upload" type="file" name="fileupload"/> <input type="submit" value="Upload"/>

</p>
</fieldset>
</form>

What scripting do you have behind action=“?x=nijmbISW*CiLQnSZCRnMstunwCVTjjZ7” ?

How can you retrieve the file in script, without using a separate jsp page to handle the form submit?

And is this form a Servoy form or is this a runtime generated form?

Martin

that what you see in the support system is just a media field!

Thats just how it works, you upload (or download) to (or from) a mediafield.

To retrieve the file is still something on the todo, you just have a mediafield column and 2 other columns mediafield_filename and mediafield_mimetype
where we then store the names

something like this:

boolean uploadFile(, || )

is impossible, that is not allowed in the web. For that just dont use a browser use a smart client then you have all the power and you are not limited by anything.

uploading a file has to go over a:

and you dont control the sourcefile name at all. that something a user has to pick by clicking on the browse button.

I guess somebody could make a WebFile plugin/bean or something that generates such a input (type=file) as above on your web page
and that will handle the upload and then you can ask it things like:

bean.getData()
bean.getFileName()

johan

Maybe the DataStream plug-in should do that.
It is already perfect for streaming data :)

jcompagner:
that what you see in the support system is just a media field!

Thats just how it works, you upload (or download) to (or from) a mediafield.

To retrieve the file is still something on the todo, you just have a mediafield column and 2 other columns mediafield_filename and mediafield_mimetype
where we then store the names

Johan,

I do not understand how I can realize this with these media fields.
Can you be more specific.

Please let me/us know what is done exactly in the support system when pressing the upload button

Martin

Martin,

If you place a field with a dataprovider of type “media” on a form and you show it in the webClient, when the field is editable it will automatically get those extra buttons to upload/save/delete the content of the media field.

Browsers in general have the restriction that if you want to upload a file, the user has to select 1 specific file manually from their local filesystem. This is a browser restriction, not something we can influence at all.

Paul

Hi Paul,

Finally I have succeeded to get these buttons like you described.
It was not clear to me how it worked.

The small upload form that I see in the support system, seems to be a standard form from the Servoy runtime.
I thought it was a small form that was build for the support system, but now I see it is a general form.
So this is what we all were looking for, but it was not clear how to use it.

Now were are going to test the upload, but first step was made!

Thanks

Martin

Upload worked.
Just one more thing.
We need the name of the file (or the complete path) that was uploaded.
Johan mentioned is his reply about several media fields (and one of them should be for the filename and one for the extension)

So, Johan, how do you exactly use there media files for the name and extension and how can you use them in server scripting?

thats currently not possible its on the todo to implement that.
Currently the only solution would be a bean/plugin that does that for you

in 4.1.1 if you have a media field “mymedia”
then you can have a column or form variable “mymedia_filename” where the filename is stored
the same thing goes for “mymedia_mimetype”

this currently only works for the web (smart has other solutions)

I need help getting the servoy_blobloader to pull my blob fields from a mysql database. I get blank images when I execute the code below within a calculation defined as media. The field type is Html_Area. I believe the problem may be with the pk.
The values have to change each time the record does.

//servername = myserver
//tablename = mytable
//dataprovider = mygraphic
//pk = img1 + img2 + img3(this is a combination pk of 3 fields) I am using the dataprovider values within servoy to get the proper values for the pk each time the record changes.

function graphics_legacy()
{
var image = ‘media:///servoy_blobloader?servername=myserver&tablename=mytable&dataprovider=mygraphic& rowid1=’+img1+‘&rowid2=’+img2+‘&rowid3=’+img3+‘’;

return ‘’;

}

Looks correct to me at a first glance, are you sure that you are using the quotes correctly? Maybe you need some escaping.

thanks for the reply, however I still can’t get this to work. I have tried this with both an html area and Image Media field type
I checked over my quotes and could not find any problems. I am running servoy 4.01, could there possibly be a bug in the system. Probably not, just a minor syntax error that’s not allowing this to work.

what does the generated html look like?

Hi,

in 4.1.1 if you have a media field “mymedia”
then you can have a column or form variable “mymedia_filename” where the filename is stored
the same thing goes for “mymedia_mimetype”

this currently only works for the web (smart has other solutions)

by following Johan’s instructions, file name and mimetype are retrieved.
Is there a way to get also the file size ?
I tryed putting a dataprovider named attach_file_size or attach_filesize, but is doesn’t work.

Also, to complete a base document management functionality, I need to save the files from the db, to the local drive of the user.
What I miss is how make the user select the path where to extract the file.
How can I do it?
If i try to use the floppy-image_media, the result is a preview of known files:
[attachment=1]preview_window.JPG[/attachment]

or the download window for unknown files (.mp3 for example) but in this case I can’t set the correct file name:
[attachment=0]save_window.JPG[/attachment]

I tryed also to save the file by default to the user desktop, but the function getDesktopFolder doesn’t work in web client.

Any suggestion is welcome !
Ric

filesize is just the number of bytes you did get…
That isnt stored anywhere else.

In the web client you cant tell a user where he must store its file. Thats up to the standard save dialog of a browser.
The same way that getDesktopFolder also doesnt work. You dont have access to that stuff.
use smart client for those things.