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.
greengAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

knightEknightCommented:
show us your form
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>
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>  
 
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

knightEknightCommented:
change the name of your submit button from "submit" to anything else like "Submit" or "btnSubmit"
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.
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>
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>

greengAuthor Commented:
Thanks again KnightEKnight...

still having troubles though even when using a the simple java alert...
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?
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
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
knightEknightCommented:
That is strange behavior.  I can't offer any thing more for now, sorry.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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!
knightEknightCommented:
thanks!  very generous of you  :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.