Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   how to show "browse for folder" dialog in html/javascript? (http://www.velocityreviews.com/forums/t162922-how-to-show-browse-for-folder-dialog-in-html-javascript.html)

strutsng@gmail.com 09-30-2005 04:20 PM

how to show "browse for folder" dialog in html/javascript?
 
<input type="file"> only allows the user to browse for files.

How about "browse for folder" dialog? Can html/javascript do that? I
couldn't find any syntax for that. If not, please advise what are the
other approaches.

please advise. thanks!!


David Dorward 09-30-2005 05:10 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
strutsng@gmail.com wrote:

> <input type="file"> only allows the user to browse for files.
>
> How about "browse for folder" dialog? Can html/javascript do that?


No.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

strutsng@gmail.com 10-01-2005 06:22 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Yes, if I use <input type="file">, I couldn't select a folder as input,
I can only select a single file as input. So there is no solution to
select a folder as input?

please advise more... thanks!!


Jukka K. Korpela 10-01-2005 07:31 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
strutsng@gmail.com wrote:

> Yes, if I use <input type="file">, I couldn't select a folder as input,


You could, in a system that treats a folder as a file. So what?

> I can only select a single file as input.


That's a common flaw in browsers (Opera being the most notable exception),
but that's completely different.

> So there is no solution to
> select a folder as input?


In a system that treats a folder as a file, there is.

> please advise more... thanks!!


Analyze what your problem really is (what is it that you are actually
trying to accomplish), explain it in plain English, and select the most
appropriate group. (Crossposting is an almost sure sign of not having
analyzed your problem.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html



Jonathan N. Little 10-01-2005 08:20 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Jukka K. Korpela wrote:
> strutsng@gmail.com wrote:
>
>
>>Yes, if I use <input type="file">, I couldn't select a folder as input,


To OP, that's because if I am not mistaken the purpose of the file field
it select a file for upload, not a folder of files.

>
> You could, in a system that treats a folder as a file. So what?


And which system is that? In DOS, Windows and Linux the directory is
just a file on the filesystem with a special directory attribute, right?
Still cannot select the folders with the file input browse dialog...

>>I can only select a single file as input.

>
>
> That's a common flaw in browsers (Opera being the most notable exception),
> but that's completely different.


Is this new for Opera? The 7.54 version that I have on W2K for testing
cannot select more than one file. Anyway isn't the browse box, at least
on Windows, the OS's common 'file open' dialog and not part of the
browser? (Just checked on Linux, it is not the same, but Windows it
certainly is!)


>>So there is no solution to
>>select a folder as input?

>
>
> In a system that treats a folder as a file, there is.
>
>
>>please advise more... thanks!!

>
>
> Analyze what your problem really is (what is it that you are actually
> trying to accomplish), explain it in plain English, and select the most
> appropriate group. (Crossposting is an almost sure sign of not having
> analyzed your problem.)
>


To OP, You could use the file input field to browse and select each
file, and then use JavaScript to append each section to a list or array.


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Joakim Braun 10-02-2005 09:05 AM

Re: how to show "browse for folder" dialog in html/javascript?
 
"Jonathan N. Little" <lws4art@centralva.net> skrev i meddelandet
news:fcC%e.273$PA1.41465@monger.newsread.com...
> Jukka K. Korpela wrote:
> > strutsng@gmail.com wrote:
> >>Yes, if I use <input type="file">, I couldn't select a folder as input,


<snip>

> To OP, You could use the file input field to browse and select each
> file, and then use JavaScript to append each section to a list or array.


But there would then be no way of uploading the files, right?

--
Joakim Braun



Jonathan N. Little 10-02-2005 12:27 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Joakim Braun wrote:
> "Jonathan N. Little" <lws4art@centralva.net> skrev i meddelandet
> news:fcC%e.273$PA1.41465@monger.newsread.com...
>
>>Jukka K. Korpela wrote:
>>
>>>strutsng@gmail.com wrote:
>>>
>>>>Yes, if I use <input type="file">, I couldn't select a folder as input,

>
>
> <snip>
>
>>To OP, You could use the file input field to browse and select each
>>file, and then use JavaScript to append each section to a list or array.

>
>
> But there would then be no way of uploading the files, right?
>
> --
> Joakim Braun
>
>


Well yes if the client has JavaScript disabled! ;-)

I would think you would need more JavaScript to enter list/array into a
form input that would be passed to some server-side script to do the
actual uploading...


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Randy Webb 10-02-2005 02:45 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Jonathan N. Little said the following on 10/2/2005 8:27 AM:

> Joakim Braun wrote:
>
>> "Jonathan N. Little" <lws4art@centralva.net> skrev i meddelandet
>> news:fcC%e.273$PA1.41465@monger.newsread.com...
>>
>>> Jukka K. Korpela wrote:
>>>
>>>> strutsng@gmail.com wrote:
>>>>
>>>>> Yes, if I use <input type="file">, I couldn't select a folder as
>>>>> input,

>>
>>
>>
>> <snip>
>>
>>> To OP, You could use the file input field to browse and select each
>>> file, and then use JavaScript to append each section to a list or array.

>>
>>
>>
>> But there would then be no way of uploading the files, right?
>>
>> --
>> Joakim Braun
>>
>>

>
> Well yes if the client has JavaScript disabled! ;-)


It wouldn't work even with Javascript enabled.

> I would think you would need more JavaScript to enter list/array into a
> form input that would be passed to some server-side script to do the
> actual uploading...


If what you are describing is possible in javascript, then anybody could
simply set the value of a hidden field to whatever file they wanted off
your PC and upload it automatically. That is not allowed (and what you
are describing) for that very reason. File inputs are very limited in
javascript context for a reason - security.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly

Jonathan N. Little 10-02-2005 03:28 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Randy Webb wrote:
<snip>
>> Well yes if the client has JavaScript disabled! ;-)

>
>
> It wouldn't work even with Javascript enabled.
>


Firstly, I am not saying the OP should do this, I think it is a bad
idea. However are you saying that you cannot build a file list of local
files using JavaScript and the file input? Because this simple codes
builds such a list....

<code>
<form>
<textarea name='abc' rows=30 cols=50></textarea>
<input type=file onchange="this.form.abc.value+=';' + this.value; return
true;">
</form>
</code>


>> I would think you would need more JavaScript to enter list/array into
>> a form input that would be passed to some server-side script to do the
>> actual uploading...

>
>
> If what you are describing is possible in javascript, then anybody could
> simply set the value of a hidden field to whatever file they wanted off
> your PC and upload it automatically. That is not allowed (and what you
> are describing) for that very reason. File inputs are very limited in
> javascript context for a reason - security.
>


Now JavaScript cannot be used to upload files, but the list sent to a
server-side script could use the list a as a queue, right? Am I
mistaken? Again, I do not think this is a very good idea...purely
curiosity and a 'what if' question.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

Randy Webb 10-02-2005 05:18 PM

Re: how to show "browse for folder" dialog in html/javascript?
 
Jonathan N. Little said the following on 10/2/2005 11:28 AM:
> Randy Webb wrote:
> <snip>
>
>>> Well yes if the client has JavaScript disabled! ;-)

>>
>>
>>
>> It wouldn't work even with Javascript enabled.
>>

>
> Firstly, I am not saying the OP should do this, I think it is a bad
> idea. However are you saying that you cannot build a file list of local
> files using JavaScript and the file input? Because this simple codes
> builds such a list....
>
> <code>
> <form>
> <textarea name='abc' rows=30 cols=50></textarea>
> <input type=file onchange="this.form.abc.value+=';' + this.value; return
> true;">
> </form>
> </code>


You can not programattically set the value of an input type="file" using
Javascript. You can read it's value, but, you can not set it's value.
And in order to upload, you have to set it's value.

>
>>> I would think you would need more JavaScript to enter list/array into
>>> a form input that would be passed to some server-side script to do
>>> the actual uploading...

>>
>>
>>
>> If what you are describing is possible in javascript, then anybody
>> could simply set the value of a hidden field to whatever file they
>> wanted off your PC and upload it automatically. That is not allowed
>> (and what you are describing) for that very reason. File inputs are
>> very limited in javascript context for a reason - security.
>>

>
> Now JavaScript cannot be used to upload files, but the list sent to a
> server-side script could use the list a as a queue, right?


It would still take user interaction. But, if you set the file name
server-side and send the page back to the browser, it will not have the
file set in the type="file" input. Try it :)

Think about the implications if you could set it:

<form name="myForm">
<div style="display:none">
<input type="file" value="Whateverfileyouwantontheserver">
</div>

<input type="text" name="usersName">

.... more legitimate inputs ....

</form>

When the user submitted the form, you could get what ever file you
wanted off the users computer. That is a very huge security risk and
because of it, you can not set the value of a file input.

> Am I mistaken?


Yes.

> Again, I do not think this is a very good idea...purely
> curiosity and a 'what if' question.


Nothing wrong with curiosity :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


All times are GMT. The time now is 02:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.