jc70
08-24-2002, 04:10 PM
I don't like the look of the input-file element, so I've tried to put it
invisible with " style="display:none" " and simulate the onclick event with another button;
something like this:
<head>
<title>Form test</title>
<script language="JavaScript">
function file_changed() {
document.upload.filen.value = document.upload.fileu.value;
}
function browse_files() {
document.upload.fileu.click();
}
</script>
</head>
<body>
<form name="upload" method="post" action="upload.asp" enctype="multipart/form-data">
<input type="file" name="fileu" onchange="file_changed()">
<br>
<input type="text" name="filen" value="">
<br>
<button type="button" name="browse" onclick="browse_files()">Browse</button>
<br>
<button type="submit" name="post">Submit</button>
</form>
</body>
</html>
The problem is that when you try to submit the form he doesn't work;
The filename from the input-file element just disappear and nothinh happen unless
you press the submit button again, but in this case no filename is posted.
If you try to do it manually like this
<button type="button" name="post" onclick="document.upload.submit()">Submit</button>
instead of
<button type="submit" name="post">Submit</button>
you get this message: "Access denied"
if you use the Browse button of the input-file element everything works fine.
What is the problem, am I doing something wrong ???
Can someone help me, please ?
Thanks
Christian
invisible with " style="display:none" " and simulate the onclick event with another button;
something like this:
<head>
<title>Form test</title>
<script language="JavaScript">
function file_changed() {
document.upload.filen.value = document.upload.fileu.value;
}
function browse_files() {
document.upload.fileu.click();
}
</script>
</head>
<body>
<form name="upload" method="post" action="upload.asp" enctype="multipart/form-data">
<input type="file" name="fileu" onchange="file_changed()">
<br>
<input type="text" name="filen" value="">
<br>
<button type="button" name="browse" onclick="browse_files()">Browse</button>
<br>
<button type="submit" name="post">Submit</button>
</form>
</body>
</html>
The problem is that when you try to submit the form he doesn't work;
The filename from the input-file element just disappear and nothinh happen unless
you press the submit button again, but in this case no filename is posted.
If you try to do it manually like this
<button type="button" name="post" onclick="document.upload.submit()">Submit</button>
instead of
<button type="submit" name="post">Submit</button>
you get this message: "Access denied"
if you use the Browse button of the input-file element everything works fine.
What is the problem, am I doing something wrong ???
Can someone help me, please ?
Thanks
Christian