Page 1 of 1

Equivalent of CMDFileOpen for Web Apps?

Posted: Wed Jun 13, 2012 9:08 pm
by Rich Cassell
Hey,

I need the user to be able to open files on their local machine and upload them to our server using our Web Enabled Forms application. The CMDFileOpen class is perfect for this but isn't available for use on server nodes... :(

Does anybody know of any good alternatives that i can use instead? If it's not possible to have an actual dialog for this then i'm happy to have other methods that work...

Thanks!

Rich

[Admininstator Update 2012/06/14]
Changed the subject from Equivalent of CMDFileOpen for server nodes to an alternate topic name of Equivalent of CMDFileOpen for Web Apps to more accurately reflect the subject matter of this thread.

Re: Equivalent of CMDFileOpen for server nodes?

Posted: Wed Jun 13, 2012 10:23 pm
by murray
If I recall correctly, I have seen this done using a dialog form with a ListBox set for hierarchical tree view, probably loaded using calls to FileFolder::files, with usePresentationFileSystem = false. It is in a file-viewer applet that I use most days, but I don't have the code here with me at the moment.
There are also FileFolder methods browseForServerFolder() and browseForAppServerFolder() to have a look at.

Re: Equivalent of CMDFileOpen for server nodes?

Posted: Wed Jun 13, 2012 11:12 pm
by Rich Cassell
Hi Murray,

Thanks for your reply. If i can avoid using applets then i'd prefer to as it could potentially cause viewing issues for some of our users - there have been occasions in the past where they have security turned up so high that things don't work!

I'll definitely take a look at the FileFolder methods you mentioned though, and also look at the ListBox option you mentioned. I'm sure one of those will give me exactly what i need.

Thanks again! :)

Rich

Re: Equivalent of CMDFileOpen for server nodes?

Posted: Thu Jun 14, 2012 1:47 am
by Rich Cassell
Hi Murray, (I'll address it in response to your message but it's an open post really :D )

I have tried various methods in a ListBox and can still only get it to reference the file structure on the hosting server, i need it to display the files on the local machine. Essentially, i'm trying to create an FTP screen... The usePresentationFileSystem seems to only work on thin client applications and doesn't have any impact on my web application.

If there's any other things i can try, or if i'm doing the above incorrectly, then i'd be very grateful of the help. I'm currently looking into embedding Javascript to try and fire off the Windows Open File Dialog...

Rich

Re: Equivalent of CMDFileOpen for server nodes?

Posted: Thu Jun 14, 2012 3:21 am
by Rich Cassell
Just extending my last post regarding me using Javascript to get the desired result, i have come across the following:

Code: Select all

<script> function openFileOption() { document.getElementById("file1").click(); } </script> <input type="file" id="file1" style="display:none"> <a href="#" onclick="openFileOption();return;">open File Dialog</a>
The function i can put in as userScript, but they key thing in the above is the <input type="file"...> section which is obviously part of the html build up of the form. What's the best way of me inserting this code into my application? Essentially, i want to be able to press a button, display the File Open Dialog containing the local machine's file structure, select a file which populates a text box with it's name and then upload it to a pre-determined location on our server...

Thanks,
Rich

Re: Equivalent of CMDFileOpen for Web Apps

Posted: Thu Jun 14, 2012 8:52 am
by BeeJay
If you want to let the users browse for a file on their local machine from a Jade Web Forms application, then you should look at the help for the TextBox::webInputType property. (EncycloWin.pdf)

Specifically you'll probably want to set this to Web_InputType_File.

Note that the file is only temporarily available for use in the method sequence that is triggered when they click the relevant "Submit" button for that form, so you have to process the file into wherever you want to store it during that submit processing.

Your topic should probably be "Equivalent of CMDFileOpen for Web Apps", so I'll change the subject shortly.

Cheers,
BeeJay.

Re: Equivalent of CMDFileOpen for Web Apps?

Posted: Thu Jun 14, 2012 9:07 am
by murray
Sorry, last night I completely missed the fact in the original post that it was for Web-enabled forms.
My response was regarding a Jade thin client app that browses for files on the server node, which is sort of the opposite situation.

Re: Equivalent of CMDFileOpen for Web Apps?

Posted: Thu Jun 14, 2012 8:21 pm
by Rich Cassell
Hi BeeJay / Murray,

Thanks again for your replies.

I think i may have confused you Murray with my original post and Subject, as BeeJay pointed out, sorry for that. Thanks BeeJay for changing it! Thanks also for pointing out the webInputType property on TextBoxes. I'll take a look at this and report back on how i get on!

Thanks for your help

Rich :)

Re: Equivalent of CMDFileOpen for Web Apps?

Posted: Fri Jun 15, 2012 12:55 am
by Rich Cassell
Works beautifully :D. Thanks for the help!

For the benefit of others, i'll just describe what i've done... Created a TextBox with the webInputType property set to Web_InputType_File. This will show a "Browse" button on the web browser. Once this is pressed and a file is selected, the text property of the field contains <filename>;<destination directory><destination filename>. The file manipulation has to be done at this stage as the file is only a .TMP at this stage. The destination directory is set in the jadehttp.ini file. I used the code below to actually move the file into it's new location on the server:

Code: Select all

doUploadClick() updating, protected; vars toUpload : File; filename, fileloc, findFile, fileDir : String; pos : Integer; ffolder : FileFolder; begin findFile := txtUploadFile.text; pos := 1; filename := findFile.scanUntil(";",pos); fileloc := findFile[pos+1:end]; if fileloc <> "" then create toUpload transient; toUpload.kind := toUpload.Kind_Unknown_Text; toUpload.allowCreate := true; toUpload.fileName := fileloc; if toUpload.isAvailable then beginTransaction; create ffolder transient; fileDir := "\\serverFolder\newFiles\"; if ffolder.isValidPathName(fileDir) then ffolder.fileName:=fileDir.toLower; if not ffolder.isAvailable then ffolder.make(); endif; endif; toUpload.rename(fileDir & "\" & filename); toUpload.close; commitTransaction; else lblErrorLine.caption := "File does not exist"; endif; else lblErrorLine.caption := "Please select a file"; endif; epilog delete toUpload; delete ffolder; end;
I've just thrown the above code together to get it working so it isn't massively efficient before anybody questions it :P. But it works so thanks for all the help.

Rich