By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

How to make file uploading work in Internet Explorer?

P: 1
Hello,

I have wrote code that uploads files from user's hard disks to the server and everything works fine in Firefox and Safari, but in Internet Explorer it uploads dummy files and cycles that. So when I try to upload one photo, I get a lot of dummy files on my server and a lot of record in MySQL insted of one record.

I guess the problem in JS:

[PHP]<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
<!--

imageWait = new Image(); imageWait.src = "http://www.roamearth.com/img/wait.gif";

function showWaitImage() {
document.getElementById('photoSubmit').disabled = true;
document.getElementById('photoSubmit').value='Зака чивается...';
var showMap = document.getElementById("showMap");
showMap.innerHTML = '<iframe src="http://www.roamearth.com/empty.html" frameBorder=0 scrolling=no></iframe>';
var mapThisPhoto = document.getElementById("mapThisPhoto");
mapThisPhoto.innerHTML = '<span></span>';

parent.changeFrameSizePhoto();
var div = document.getElementById("image");
div.innerHTML = '<table width="100%" cellspacing="0" cellpadding="0"><tr><td align="center"><span class="style">Фотография закачивается, пожалуйста подождите...<br /><br />&nbsp;<br />&nbsp;<br /><img src="http://www.roamearth.com/img/wait.gif" id="myImage" /></span></td></tr></table>';
document.getElementById("myImage").onload = function() {
document.getElementById("photoForm").submit();
}
return false;
}

//-->
</SCRIPT>[/PHP]

The form looks like it's ok:
[PHP]<form name="photoForm" id="photoForm" action="uploadsub.php?geo=3017382&dest=&typet=ph&l ang=ru" method="post" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="4000000" /><input size="15" name="url" type="file" style="border:1px solid #777777" class="style">
<input value="Закачать" type="submit" class="style" name="photoSubmit" id="photoSubmit" onclick="return showWaitImage()"></form>[/PHP]

In ShowWaitImage() function everthing works until this:
[PHP]document.getElementById("myImage").onload = function() {
document.getElementById("photoForm").submit();
}[/PHP]

I wonder what part of code doesn't work in IE? Why that happens?

PS: Live example is here (login "test", pass "thetest"):
http://www.roamearth.com/upload.php?...&tpage=country
Jan 5 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
It may have something to do with how IE loads images. Why are you submitting the form on image load?
Jan 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.