Solved

How to upload local file?

Posted on 2002-03-12
19
200 Views
Last Modified: 2010-04-09
Hi, there,

I need to implement following feature to my HTML:

*********************************************
text field 1           browser button 1
text field 2           browser button 2
.....

submit button
*********************************************

I need to click on each "browser button" and choose a local file name from a popup window, and put this file name into corresponding "text field".  When I click the "submit button", all local file in those text fields will be uploaded.

Can anybody tell me how to do that?

Daisy
0
Comment
Question by:DaisyWang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +3
19 Comments
 
LVL 18

Accepted Solution

by:
bruno earned 50 total points
ID: 6858005
you need a component on your server to allow it...

like: http://www.softartisans.com/softartisans/saf.html

then on your page you do...


<input type="file" name="file1">



BRUNO
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6859372
give BRUNO the points before i copy and paste what he's written!
0
 
LVL 18

Expert Comment

by:bruno
ID: 6859514
lol...i lucked out and managed to be the first one here.  :-)
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 

Author Comment

by:DaisyWang
ID: 6860963
maybe you are same guy, haha :)
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6870726
no im lexxwern
bruno is not lexxwern
also
lexxwern is not bruno

hope this helps, now DaisyWang you owe me points.

lhn
0
 
LVL 18

Expert Comment

by:bruno
ID: 6871329
Daisy,

did what I posted help you at all?

Somewhat rude to come back and not comment on the problem at hand....


BRUNO
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6875929
BRUNO its hurts even more when someelse is living in a more favourable timezone.
+0530 INDIA is really a bad one. i get no new quetions whether i log on in the evening or morning :-(

i guess you ppl have taken full adv. of reading the brief history of time, huh!?

Anyway,

lexxwern
0
 
LVL 18

Expert Comment

by:bruno
ID: 6875950
lexxwern,

i have no idea what your comment has to do with the issue at hand.


BRUNO
0
 

Author Comment

by:DaisyWang
ID: 6877024
bruno,

i'm trying your way these days, give me some time, if it works, i'll surely give you your points.

daisy
0
 
LVL 18

Expert Comment

by:bruno
ID: 6877272
Daisy,

Thanks for coming back and commenting, let me know if you have any problems.  


BRUNO
0
 
LVL 1

Expert Comment

by:NTIVER
ID: 6879712
Daisy:

The upload part will have to be done with some server side code as bruno suggests, but you could use javascript to populate text boxes with the two filenames you've browsed for if you wish.

If you're bored, give this a try and see what you think:

<html>
<head>
<script>
function populate_texts()
{
var selected1 = document.form1.file1.value
var selected2 = document.form1.file2.value

var seperated1 = selected1.split("\\");
var seperated2 = selected2.split("\\");

var no_of_sections1 = seperated1.length;
var no_of_sections2 = seperated2.length;

var last_portion1 = (no_of_sections1 -1);
var last_portion2 = (no_of_sections2 -1);

var filename1 = seperated1[last_portion1];
var filename2 = seperated2[last_portion2];

document.form1.text1.value = filename1
document.form1.text2.value = filename2
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="text1">&nbsp&nbsp<input type="file" name="file1">
<p>
<input type="text" name="text2">&nbsp&nbsp<input type="file" name="file2">
<p>
<input type="button" name="submitbutton" value="submit" onClick="populate_texts();">
</form>
</body>
</html>

All you'd need then is he active code to do the processing of the text boxes.

There's probably other ways, I was just killing time over a Lobster Thermidore luncheon :)

Neil
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6881484
lexxwern,
Hello, I am Computer101, a Moderator on this site.  I have an issue with your comment.  What gives you the right to DEMAND that the questioner "give BRUNO the points before i copy and paste what he's written! ".  We are here to assit questioners, not demand things from them.  The questioner's history for accepting answers is not that great, but that give's you the right?  Also, what input to the questioners problem did you provide.  As I see it, nothing, so why did you post in this thread. I will monitor your actions and we will see how things go, but I ask that you tone things down.  If no related posts continue to be made, I will forward this to Admin for action.

Btw, I will not accept anymore comments in this questioner's thread concerning this but will open a question in Community Support concerning this matter.

Now DaisyWang, you do have open questions and I ask that you resolve those or I will have to go back to them and close them.

Thank you
Computer101
E-E Moderator
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6883148
Explanation and Clarifications Posted here
http://www.experts-exchange.com/questions/Q.20279061.html


--------------------COPY--------------------
 okay.
i better get to say something.

first thnx big rat.

Daisy Said " maybe you are same guy, haha :)"
*Please note 'haha'* and my reply
     " no im lexxwern
       bruno is not lexxwern
       also
       lexxwern is not bruno

       hope this helps, now DaisyWang you owe me points.

       lhn"
was in the same tone

my comments there were not demanding anything, my comments weren't even serious, i guess bruno got that
by his saying "lol...i lucked out and managed to be the first one here.  :-)".

as you first language english havers say, i was kidding.

i also acknowledge that my comments there were not related to the topic and i will prevent "cluttering"
in the future.
but i would not want people incharge here to believe that i was in any way demanding anything from EE
User DaisyWang.

now i would ask Computer101 to delete this thread if it has solved its purpose, since it is not doing
me any favours.

lexxwern.
--------------------END----------------------
0
 
LVL 2

Expert Comment

by:coreyit
ID: 6888132
Sorry to get off topic and back to DaisyWang's question, but...

it's my understanding that any form submission that includes files requires that
    enctype="mulitpart/form-data"
be added to the form tag.

Regarding the javascript form field population from NTIVER, no need: <input type="file"> provides it's own field that displays the path to the selected file.

-corey
0
 
LVL 1

Expert Comment

by:NTIVER
ID: 6888218
coreyit - I know, I was just stripping the path details so that the user could grab just the filename and extension.

I didn't know if it might be of use.

Neil :)
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6923234
Daisy,
Any status.

Thank you
Computer101
E-E Moedrator
0
 
LVL 18

Expert Comment

by:bruno
ID: 6926663
C101, I think you know what I'm gonna say here....

DaisyWang, you've been blacklisted for giving a C grade and not giving a comment why.


BRUNO
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6927210
After review, grade changed.

Computer101
E-E Moderator
0
 
LVL 18

Expert Comment

by:bruno
ID: 6927273
thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question