• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3311
  • Last Modified:

Problems with <input type="file">

Hi everyone

I'm hoping that someone can help me out with this because its driving me crazy!

On my site i have a link that allows users to upload images.  When they click the link a java created pop up window is displayed which asks users to locate the file on thier computers through the use of <form> tags and a <input type="file" name="fileName"> input field.  Upon hitting the submit button, they user is taken to a page where my ASP script handles the file.  

The problem that im having is that for some reason everytime i hit submit with a value in the file input field (ie. someone has choosen a specific file to upload), the file field becomes blank the form won't submit to the next page.  Only when no value has been entered in the file field does the submit button actually work.

Now, i tried to simplify the code as much as possible so i don't think i've made a mistake because i've done procedures similar to this a few times at other places on the site.  I've also taken the code and called the file outside of the java pop-window and its worked fine.

Has anyone ever heard of an issue with <input type="file"> and java pop-ups?  Shouldn't i be able to do this?

Any suggestions or work arounds would be greatly appreciated.
Thanks in advance.
0
greeng
Asked:
greeng
  • 7
  • 7
1 Solution
 
knightEknightCommented:
show us your form
0
 
greengAuthor Commented:
Okay, this is the super simplified version.  Now, don't get me wrong, it works fine, just not in a pop up window.
Like, I can't make it any more basic then that.....


<html>
<head>
<title>Upload Company Logo</title>
</head>
<body>
  <form name="customLogo" method="POST" enctype="multipart/form-data" action="user_image_upload_submit.asp">
<input type="text" name="fileName" size="40">
<input type="submit" name="submit" value="Submit Your Image">
</form>
</body>
</html>
0
 
greengAuthor Commented:
whoops...  this is what i ment to post (the input type is set to text.. i was just testing something out...)

 Comment from knightEknight
Date: 11/14/2003 06:09AM PST
 Comment    

show us your form

 
Comment from greeng
Date: 11/14/2003 06:13AM PST
 Your Comment  

Okay, this is the super simplified version.  Now, don't get me wrong, it works fine, just not in a pop up window.
Like, I can't make it any more basic then that.....


<html>
<head>
<title>Upload Company Logo</title>
</head>
<body>
  <form name="customLogo" method="POST" enctype="multipart/form-data" action="user_image_upload_submit.asp">
<input type="file" name="fileName" size="40">
<input type="submit" name="submit" value="Submit Your Image">
</form>
</body>
</html>  
 
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
knightEknightCommented:
change the name of your submit button from "submit" to anything else like "Submit" or "btnSubmit"
0
 
knightEknightCommented:
The form object has a method called "submit()" and if you name one of your form elements the same thing (as you did with your submit button) you over-write the submit() method.  So if you rename the button, the form can be submitted.
0
 
greengAuthor Commented:
Thanks for your suggestions knightEKnight but no dice.  The form just simply erases what was entered in the file input field and does nothing.


... just in case....

<html>
<head>
<title>Upload Company Logo</title>
</head>
<body>
  <form name="customLogo" method="POST" enctype="multipart/form-data" action="user_image_upload_submit.asp">
<input type="file" name="fileName" size="40">
<input type="submit" name="btnSubmit" value="Submit Your Image">
</form>
</body>
</html>
0
 
knightEknightCommented:
all I did was change the action and it works for me:

<html>
<head>
<title>Upload Company Logo</title>
</head>
<body>
 <form name="customLogo" method="POST" enctype="multipart/form-data" action="javascript:alert(document.customLogo.fileName.value);">
  <input type="file" name="fileName" size="40">
  <input type="submit" name="btnSubmit" value="Submit Your Image">
 </form>
</body>
</html>

0
 
greengAuthor Commented:
Thanks again KnightEKnight...

still having troubles though even when using a the simple java alert...
0
 
knightEknightCommented:
hmm ... you mean if you cut-n-paste what I posted above and open it in a browser the alert doesn't show up?  What browser are you using -- and what version?
0
 
greengAuthor Commented:
Yeah, i cut and pasted your code from above, reuploaded it to my server then tried opening a file.

What happends is that when a file is selected using the "Browse.." button it shows the path in the file input field, upon hitting submit all it does is clear the text box, like the action isn't even executed.  BUT if there is nothing in the path field, like if i simply open the file and hit submit without selecting any file with the "Browse.." button (or typing any text in the file input), i see the alert box displaying no message.

The browser i am using is IE 6.0
0
 
greengAuthor Commented:
Also, this probelm is only happening with the "file" input type

If i select <input type="text" name="txtBox"> or whatever when I hit submit the value that i typed in appears in the java alert box without any troubles
0
 
knightEknightCommented:
That is strange behavior.  I can't offer any thing more for now, sorry.
0
 
greengAuthor Commented:
Yeah, I'll have to try to re-write stuff and see if i can get something to work

If any one has any more suggestions i'd really like to hear them


Thanks though KnightEKnight, points for effort my friend!
0
 
knightEknightCommented:
thanks!  very generous of you  :)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now