View Full Version : Open Files
02-28-2003, 02:28 PM
I have 2 problems, listed bellow:
Thanks any help.
02-28-2003, 02:59 PM
You don't set the value of a <input type="file"> tag. You can only get the value as set by the client, if your script could set the value websites could easily get any file they wanted from the client's computer, often without the user even knowing they've been robbed. It's a security thing, the browser will never let you set the value.
02-28-2003, 05:18 PM
Thanks for your reply, and for the 1st. question, do you have any trip???
02-28-2003, 07:33 PM
Actually my response was to part 2 of your question, the <input type="file" /> tag you were using is the answer for part 1 of your question. The key thing to know is that you cannot script that form field for the user, they'll have to use that input field to navigate to the file themselves. That usually means some rather detailed instructions depending on the level of the users.
02-28-2003, 07:35 PM
It's much better to open files with a server-side language but if you must have a client-side solution here is an (IE) ActiveX object. Due to security, you will receive a prompt.. only by clicking yes will the file be loaded.
var fso = new ActiveXObject('Scripting.FileSystemObject');
var fs = fso.OpenTextFile(f);
document.formName.fileContent.value = fs.ReadAll();
<textarea name="fileContent" rows="20" cols="100%"></textarea>
<input type="file" size="40" onchange="readFile(this.value)" />
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.