If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Urgent:<input type="file"> IE Incompatabilities

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-04, 00:55
sachin_mt sachin_mt is offline
Registered User
 
Join Date: Jan 2003
Posts: 106
Urgent:<input type="file"> IE Incompatabilities

We are using ASP to upload a file.

We have <input type="file"> which allows the user to choose a file.

But user can type any junk into the file text box and when he clicks on Upload button it uploads an empty file with the junk given as file name.

We need to prevent this.I can use <input type="file" READONLY>,But this works fine on IE5 but on IE6,the Browse button does not open the dialog box at all.

Do you have any workaround for this which will work on both IE5 and IE6.

Its urgent
__________________
Sachi
Reply With Quote
  #2 (permalink)  
Old 04-06-04, 23:03
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
What is the component you are using to upload file? Usually you can check the file size, extension and so on. You do not need to put READONLY there.
Reply With Quote
  #3 (permalink)  
Old 04-06-04, 23:42
sachin_mt sachin_mt is offline
Registered User
 
Join Date: Jan 2003
Posts: 106
yes

Hi,

You are right,But I want to prevent users from typing some junk into the file text box.How shall I do it then???
__________________
Sachi
Reply With Quote
  #4 (permalink)  
Old 04-07-04, 00:52
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
try this....

<body>
<form name="frmTest" id="frmTest">
<input type="file" onkeydown="return false;" onkeypress="return false;" id="testfile">
</form>
</body>

you can still right click and cut or paste from the field, but if you using onmousedown it theory you should be able to disable that as well.

Last edited by rokslide; 04-07-04 at 01:05.
Reply With Quote
  #5 (permalink)  
Old 04-07-04, 01:14
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
new version for you....
Code:
<script>
function test(){
	if(window.event.button==2) {
		alert('Please use the browse button');
		return false;
	}
	else {
		return true;
	}
}
</script>
<body>
<form name="frmTest" id="frmTest">
<input type="file" onmousedown="return test();" onkeydown="return false;" onkeypress="return false;" id="testfile">
</form>
</body>
tested under ie 5.5
Reply With Quote
  #6 (permalink)  
Old 04-07-04, 01:17
sachin_mt sachin_mt is offline
Registered User
 
Join Date: Jan 2003
Posts: 106
thanx rokslide

Thanx a lot rokslide,

You have solved out problem,

I hope this thread wil be very usefull for many guys facing the same problem over the net.
__________________
Sachi
Reply With Quote
  #7 (permalink)  
Old 04-07-04, 01:31
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
It's probably possible to fake the page of course and try to submit a file that doesn't exist.... there is nothing you can really do about that though.... and I very much doubt it will work with Netscape/Mozilla/Gecko browsers....

But for your problem it should be fine....
Reply With Quote
  #8 (permalink)  
Old 04-07-04, 01:54
sachin_mt sachin_mt is offline
Registered User
 
Join Date: Jan 2003
Posts: 106
is it possible to allow just left and right arrows

This works fine but

The user will not be able to see the entire path in the file text box after choosing the file using Browse button,since he cannot use arrow keys,is it possible to allow just arrow keys so that user can see the entire path but not able to type any characters.

Only if possible otherwise its ok.
__________________
Sachi
Reply With Quote
  #9 (permalink)  
Old 04-07-04, 02:09
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
try this.....
Code:
<script>
function test(){
	if(window.event.button==2) {
		alert('Please use the browse button');
		return false;
	}
	else {
		return true;
	}
}
function test2(){
	if(window.event.keyCode==37||window.event.keyCode==39){
		return true;
	}
	else {
		return false;
	}
}
</script>
<body>
<form name="frmTest" id="frmTest">
<input type="file" onmousedown="return test();" onkeydown="return test2();" onkeypress="return test2();" id="testfile">
</form>
</body>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On