• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JQuery for file upload related functionality

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am usually a server side programmer, but now I have a need to get a list of files from one specific folder on the client (where the browser runs). I have been trying to use JQuery file upload feature, and while it works, and does open a miniature Explorer feature, it is just overkill for me, and I don't know how to get what I want from it. Is there an easier way for me to specify a folder name and get a list of files that are present in the folder?

I have also tried to look at Apache HttpClient, but there is just so much unknown stuff there for me to learn, that my head hurts from trying to do, what is possibly a rather simple thing to do.

Any help is much appreciated. Thanks!

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to be clear: are you saying that you want to have something which runs in a browser and, without the user's agreement, takes a file from the machine where the browser is running and uploads it to your server?

This sounds to me like a serious violation of security, and so I wouldn't expect you could do that from a component which the user hasn't been asked to accept as secure (such as your Javascript code).
 
Maya Raman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually no, I do not want to upload the file (at least not in this case). I just want to display a list of files from say, C:\Test, back to the user in a listbox.

It is very similar to the first step of file upload on a mail client... but instead of showing the user the entire file explorer, I want to restrict it to one folder (and one file type).

Also wanted to add that this is a secure application meant for a closed audience, over the intranet.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What jQuery feature are you talking about? JavaScript has no access to the client file system, so I'm not sure what feature you are talking about, unless there's some plugin that cooperates with an IE ActiveX control?

And, please check your private messages for an important administrative matter. Thanks.
 
Maya Raman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JQuery file upload is what I have now.

Oh, I see how my language could have been misleading. I do not want the list of files, but rather a list of file names, and these filenames will be displayed to the user where he/she would pick one.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it seems to me that the jQuery file upload component already does all the things you asked for in your original post. The only thing it might not do is to start in a specific directory.

Here's a link to a page which tells you how to use the component: How to use only the Basic plugin (minimal setup guide) -- although I expect you should have seen that page already. At the bottom are links to the API and options for the component.

Perhaps you've seen those already as well. I don't see anything in them where you specify the starting directory, but I don't really find that surprising because generally Javascript code shouldn't know about directories on the client anyway.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's a plugin -- not part of the jQuery core. That's important to point out because plugins can be written by anybody, and are not guaranteed to be robust unless tsted and endorsed by the core group. (Though in this case, the plugin looks pretty good.)

[Edit: As customary, Paul snuck his post in before mine.]

In any case, what you are asking for appears to be exactly what the plugin demo is doing. Is that not what you are after?
 
Maya Raman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul. I have already seen those links and have been playing with them for some time now. There are two big problems - the look and feel is not at all what I need, and plus there isn't a way to specify a start folder, file types etc.
And so, it is taking me for too long, which is why I thought maybe there is an easier way to do this. I do not know much about HttpClient - can that help me do what I need to do?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maya Raman wrote:Thanks Paul. I have already seen those links and have been playing with them for some time now. There are two big problems - the look and feel is not at all what I need


That is just likely a matter of CSS.

and plus there isn't a way to specify a start folder


There won't be. As has already been pointed out twice, JavaScript has no access to the file system directly. The file system in only available via the HTML file input, and it doesn't give us that ability.

file types etc.


The plugin does allow you to specify the legal file types. That doesn't prevent anyone from picking them in the file browser, but if an illegal file is chosen, it's not allowed to be uploaded. That's about the best that can be done given the limitations imposed by the browser.

I do not know much about HttpClient - can that help me do what I need to do?


No. It has nothing at all to do with all of this. That's like asking if a spoon will help you climb a tree.
 
Maya Raman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That's like asking if a spoon will help you climb a tree.



I had no idea I was so off the mark. Guess I got confused by reading somewhere about HttpClient and FileUploads...
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, HttpClient is an Apache project which simplifies the process of accessing web sites from Java code. So being written in Java, it wouldn't be useful in a Javascript environment.
 
get schwifty. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic