...

View Full Version : Upload Question



Leinad
09-25-2003, 02:50 AM
Dear JavaScript Guru,

I have posted a similar question before, but I just like to ask your suggestion on what to do.

I want to upload some files to the server, but because user often typed in an incorrect path for the file, we are going to stop them doing that by mocking up an "input field + button".
(see attached file)

What I want to perform is to:
- click the 2nd Browse Button and select the file.
- the path appears on the input box.
- upload the File.

but when I clicked upload, the path disappeared!!! can anyone please help me!

glenngv
09-25-2003, 03:36 AM
Even if you'd be successful with it, you should always check on the server if the attached file exists. So why bother with it?

Leinad
09-25-2003, 03:59 AM
or to be simple, if the path is correct in the "input box", and the CGI program is called, will I still be able to upload the file even if I don't use the <input type=file"> ?

glenngv
09-25-2003, 04:03 AM
I think the file field is required for upload to be successful

cheesebag
09-25-2003, 05:33 AM
Two many form tags!

The problem with that script is that it's not designed for what you want to do, just to provide a 'dummy' file upload button that can be labeled and styled. Try this:


<html>
<head>
<title>Uploader</title>
</head>
<body>
<br />
<form name="LANSA" onsubmit="FileToBeSent.disabled=true">
<div style="position:relative;height:30px;margin:0px 4px;">
<input id="dummyfile" type="text" name="FileToBeSent" readonly="readonly"
style="position:absolute;top:2px;left:0px;width:148px;font:11px 'comic sans ms';color:darkred;" />
<input id="realfile" type="file" name="Filename"
style="position:absolute;top:0px;left:8px;clip:rect(auto auto auto 142px);"
onclick="document.getElementById('dummyfile').value=this.value"
onchange="document.getElementById('dummyfile').value=this.value" />
</div>
<input type="submit" value="Upload" />
</form>
</body>
</html>

IE doesn't do onclick for file inputs, and moz ignores onchange so, both are covered. Disabled the 'dummy' textfield onsubmit to keep it from cluttering up the data. If this doesn't work in Opera, keep it to yourself. :p hth

<edit type="angry">Please remove LINEFEEDS where this editor has broken the code (width:148px;fon<-----).</edit>

Leinad
09-25-2003, 07:51 AM
Thanks man!
I think putting a text field with readonly attribute on top of the file field is the only way to go too... really can't think of other way...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum