Hello,
In my new web app I need to send a file (small file) from a local folder from client to the server
like File Uploader but without the client carry manually the file into the File Uploader.
Is possible automate File Uploader or use always another way to make it?
Thank you for help
No
The browser will not allow this
Ciao Antonio,
but can I put automatically into File Uploader the file?
Ciao Marco,
it’s not a limit in Xojo.
Is the browser that will not allow this.
Think about it: you visit a page and an hacker could load a file from your HD.
Ciao Antonio,
But can I filter the file when I press “+” on the File Uploader?
In this way I resolve the question:
because the client is guided to put the correct file into file uploader.
Grazie.
yes and no…
you can add a “filter” but some browser works with extensions, most with mime type.
If your file has a custom extension then you will have some trouble.
However you can try this in the shown event (fileuploader)
dim ft() as string
//For mime types you can use the fileType editor, define your types and list them in this way
ft=MyFileTypesToUpload.All.split(";")
//in this case probably you will have an extra element so remove it
if ft.ubound>-1 and ft(ft.ubound)="" then ft.remove ft.ubound
//Otherwise you can add manually for example an extension
ft.append ".pdf"
//Now the code
dim js() as String
js.Append "var o=document.getElementById('"+me.ControlID+"');" //search the fileUploader
js.Append "if (o) {" //if exists
js.Append "var fs=o.getElementsByTagName('input');" //search the input elements
js.Append "if (fs.length) {" //if there are elements
js.Append "var f=null;"
js.Append "for(var i=0;i<fs.length;i++) {if (fs[i].type=='file') {f=fs[i]; break;}}" //search the input[file]
js.Append "if (f) { f.accept='"+join(ft,",")+"'}" //set the filter
js.Append "}"
js.Append "}"
ExecuteJavaScript join(js , " ")
Now you have your filter
Remember to recheck server side. NEVER belive on the data you get from the browser
ThankYou Antonio,
this afternoon I try to implement your suggestion.
Grazie 1000, ciao.