To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Discussion > Echo Lounge

Echo Lounge General Chat and Introductions. A catch all for any topic.

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-05-2002, 12:30 PM   #1
mm00
Junior Member
 
Join Date: Sep 2002
Posts: 3
Question Problem with JavaScript and Fileupload

Hi...

I'm not sure if anyone here can help me, but I'll try anyway.

In short, my problem is follows:
<HTML>
<HEAD>
<script language="JavaScript">
<!--
function FileUpload()
{
document.form1.fileselect.click();
}
//-->
</script>
</HEAD>
<BODY>
<form name="form1" action="action.php" method="post" enctype="multipart/form-data">
<img src="imgview.php?filename=$filename" onClick="FileUpload()">
<input type=file size=25 maxlength=500000 name="fileselect" accept="image/*">
<input type=submit name="OKbutton" value="OK">
</form>
</BODY>
</HTML>

Now, if I click on the image, the file selection appears, I can select the file, and it appears in the input. But, once I click OK, all it does is to clear the file selection. If I chose the file manually by clicking on "Browse..." and then press the OK button, the file is sent to the action.php. I noticed this behaviour in IE 6. Mozilla and Opera simply ignore the Javascript completely.

Any suggestions on why the submit button only clears the input field, and how to fix this?

Thank you.


Marc
mm00 is offline   Reply With Quote
Old 09-13-2002, 04:18 AM   #2
chingwaah
Junior Member
 
Join Date: Sep 2002
Posts: 23
I don't know what "
<img src="imgview.php?filename=$filename" onClick="FileUpload()"> " suppose to do.

When you use <INPUT type="file"...> the client browser will upload the selected file to the server, to a temporary directory. All you do is to find where this information is at so you can copy the file to your permanent directory.

PHP provide this information for you.via $_FILE array.

Example:

To copy your file to permanent directory, just use

move_uploaded_file($_FILES['fileselect']['tmp_name'], "mydirectory/myimg.gif");


Good luck!

Visit me at http://www.bringitlive.com
__________________
chingwaah is offline   Reply With Quote
Old 09-13-2002, 07:30 PM   #3
bealers
Member
 
bealers's Avatar
 
Join Date: Aug 2002
Location: Worcestershire/UK
Posts: 37
Hmm just had a quick look here:
<http://developer.netscape.com/docs/m...sref/index.htm>
and could't see fileSelect, is this IE specific? Is click() a valid method?

--
;D
bealers is offline   Reply With Quote
Old 09-13-2002, 08:10 PM   #4
chingwaah
Junior Member
 
Join Date: Sep 2002
Posts: 23
Look at the original message. There you'll find "fileselect" as a name of a field in the hform.

Hopes this clarafies it.

http://www.bringitlive.com

PS: it helps to read thoughly.
__________________
chingwaah is offline   Reply With Quote
Old 09-14-2002, 04:13 AM   #5
bealers
Member
 
bealers's Avatar
 
Join Date: Aug 2002
Location: Worcestershire/UK
Posts: 37
Thumbs down

Thanks for the patronising tone, do you practice that?
bealers is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Forum Jump


All times are GMT -4. The time now is 02:58 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.