p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   HTML Code Clinic (http://p2p.wrox.com/forumdisplay.php?f=90)
-   -   File Field problem (http://p2p.wrox.com/showthread.php?t=4128)

vixy September 22nd, 2003 08:03 AM

File Field problem
 
An enquiry for a developer friend of mine (He has to go with Java functionality so this may not be relevent): He wants a File Field to have an initial value, also, he wants the user to select a folder rather than a file. Is this possible?


Imar September 22nd, 2003 08:30 AM

Nope. The browser prohibits you from setting an initial value because it's inherently insecure.

Consider the following example:
Code:

<body onload="document.Form1.submit();">
<form method="post" name="Form1">
<input type="file" value="C:\My Documents\MySecretFile.doc">
</form>
</body>

As you can see from this example, allowing an initial value in a file control, would allow you to upload any file (if you know the name) from your visitor's computer by having the form automatically submit when the page loads.

You also can't select a folder; all you can do with the <input type="file"> control is allow a single file. There may be third party controls available for this, but personally I don't know one that can do this.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


All times are GMT -4. The time now is 09:44 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.