Hi,
I have a file upload script that uses a iframe to load a image to the server while staying on the same page but for some reason it only works in google chrome and not IE or firefox, can anybody help with this…
here’s the main part of the code for the upload of the image
function startUpload() {
document.getElementById('photo_uploader').innerHTML="<img src='images/loader.gif' />";
return true;
}
function stopUpload(result) {
if (result == 1) {
alert('update image');
}
}
<!-- BODY BELOW -->
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<div id="photo_uploader">
<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload()">
<input name="myfile" type="file" size="30" />
<input type="submit" name="submitBtn" class="sbtn" value="Upload" />
</form>
</div>
And here’s the upload.php script below
$timestamp = time();
$result = 0;
$_FILES["myfile"]["name"] = $timestamp."_".$_FILES["myfile"]["name"];
$filename = $_FILES["myfile"]["name"];
if ((($_FILES["myfile"]["type"] == "image/gif") || ($_FILES["myfile"]["type"] == "image/jpeg") || ($_FILES["myfile"]["type"] == "image/pjpeg")) &&
($_FILES["myfile"]["size"] < 900000))
{
if ($_FILES["myfile"]["error"] > 0)
{
}
else
{
if (file_exists("upload/" . $_FILES["myfile"]["name"]))
{
}
else
{
$filename = "http://server/upload/".$filename;
move_uploaded_file($_FILES["myfile"]["tmp_name"],
"upload/" . $_FILES["myfile"]["name"]);
$result = 1;
$query = "UPDATE users SET url = '$filename' WHERE userid='$userID'";
mysql_query($query);
}
}
}
else
{
}
sleep(1);
?>
<script language="javascript" type="text/javascript">parent.stopUpload(<?php echo $result; ?>);</script>
is it something to do with the parent.Function as to why it doesn’t work in IE or firefox?
Thanks in advance?