471,582 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Multiple images are not uploading to an iframe in firefox

I am using iframe to store uploaded images, it is uploading fine in IE but it is not happening in firefox means first time it is uploading image if i try to upload second image it is not calling even java script function and not uploading the image in firefox. I am using this code in the button onclick event "attach_frame.upload();" here attach_frame is the iframe name and id to which the uploaded image should add. please can any one help me to solve this problem
regards
tram
Sep 13 '07 #1
4 3538
dmjpro
2,476 2GB
I am using iframe to store uploaded images, it is uploading fine in IE but it is not happening in firefox means first time it is uploading image if i try to upload second image it is not calling even java script function and not uploading the image in firefox. I am using this code in the button onclick event "attach_frame.upload();" here attach_frame is the iframe name and id to which the uploaded image should add. please can any one help me to solve this problem
regards
tram
Don't do double Post.

Kind regards,
Dmjpro.
Sep 13 '07 #2
Death Slaught
1,137 1GB
I am using iframe to store uploaded images, it is uploading fine in IE but it is not happening in firefox means first time it is uploading image if i try to upload second image it is not calling even java script function and not uploading the image in firefox. I am using this code in the button onclick event "attach_frame.upload();" here attach_frame is the iframe name and id to which the uploaded image should add. please can any one help me to solve this problem
regards
tram
Please post your code/site so we can find the possible errors in your code.

Thanks, Death
Sep 13 '07 #3
Please post your code/site so we can find the possible errors in your code.

Thanks, Death
With u r response i am sending link of my site " www.storyclix.com" in that go to "add my story" and in that media section is there. try to upload multiple images u can find the problem easily. Problem is in firefox not in IE in IE it is uploading correctly.


<?php

function Compress_Gen_Thumb_Image($ori_file, $new_file, $ext)
{
//echo "<br>Src file = ".$ori_file." Dest file = ".$new_file." Ext = ".$ext;
$zzzzz = explode('.',$new_file);

$size = 0.99;
list($oriw, $orih) = getimagesize(trim($ori_file));
//echo "<BR>Original : Width = ".$oriw." , Height= ".$orih;
$wid = $oriw;
$hei = $orih;
$dest_file = "";
$filename = "";

$new_file = 'temp/'.$new_file;

while(($wid>65)||($hei>65))
{
$wid = $oriw * $size;
$hei = $orih * $size;
$size = $size - 0.01;
}
//echo "<BR>Thumb : Width = ".$wid." , Height= ".$hei;

if(($ext=='jpg')||($ext=='jpeg'))
{
// Resizing the Image
$tn = imagecreatetruecolor($wid, $hei);
$image = imagecreatefromjpeg($ori_file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $wid, $hei, $oriw, $orih);

// Outputting a .jpg, you can make this gif or png if you want
//notice we set the quality (third value) to 100
imagejpeg($tn, $new_file, 100);
}
if($ext=='gif')
{
$tn = imagecreatetruecolor($wid, $hei);
$image = imagecreatefromgif($ori_file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $wid, $hei, $oriw, $orih);
imagegif($tn, $new_file);
}
if($ext=='png')
{
$tn = imagecreatetruecolor($wid, $hei);
$image = imagecreatefrompng($ori_file);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $wid, $hei, $oriw, $orih);
imagepng($tn, $new_file);
}

}




function Generate_Versioning_name($fname)
{

if(file_exists($fname))
{
$filee = $fname;
$count = 0;
$temp_splited_dir = explode('/',$filee);
$filename = $temp_splited_dir[1];
$temp_splited_file = explode('.',$temp_splited_dir[1]);
$new_f_name = "temp/".$temp_splited_file[0].".".$temp_splited_file[1];
$thumb_image = trim($temp_splited_file[0])."_1.".trim($temp_splited_file[1]);
$count = 1;
if(file_exists($new_f_name)=='1')
{
while(File_Exists_or_Not($new_f_name)=="true")
{
$new_f_name = 'temp/'.$temp_splited_file[0]."_".$count.".".$temp_splited_file[1];
$thumb_image = trim($temp_splited_file[0])."_".$count."_1.".trim($temp_splited_file[1]);
$count = $count + 1;
}
$newfile = $new_f_name;
}
else
{
$newfile = $new_f_name;
}
}
else
{
$temp_splited_dir = explode('/',$fname);
$filename = $temp_splited_dir[1];
$temp_splited_file = explode('.',$temp_splited_dir[1]);
$thumb_image = trim($temp_splited_file[0])."_1.".trim($temp_splited_file[1]);
$newfile = $fname;
}
return $newfile."#".$thumb_image;
}

function File_Exists_or_Not($FILE)
{
if(file_exists($FILE))
{
return "true";
}
else
{
return "false";
}
}



$ftmp = $_FILES['image0']['tmp_name'];
$oname = $_FILES['image0']['name'];
$fname = 'temp/'.$_FILES['image0']['name'];

$exteee = strrev($oname);
$revext = substr($exteee,0,strrpos($exteee,'.'));
$ext = strtolower(strrev($revext));

if(($ext=='jpeg')||($ext=='jpg')||($ext=='gif')||( $ext=='png'))
{
$filetype = 'IMAGE';
}
if($ext=='flv')
{
$filetype = 'VIDEO';
}
if($ext=='mp3')
{
$filetype = 'AUDIO';
}
if($_FILES['image0']['name']!='')
{
$filee = $fname;
$newfile = Generate_Versioning_name($fname);

$ori_thumb_image_names = explode('#',$newfile);
$newfile = $ori_thumb_image_names[0];
$thumb_image = $ori_thumb_image_names[1];
//echo "<br>ori : ".$newfile."<br>thum : ".$thumb_image;


}
if($ext=='flv')
{
if($_FILES['image1']['name']!='')
{
$ftmp1 = $_FILES['image1']['tmp_name'];
$oname1 = $_FILES['image1']['name'];
$fname1 = 'temp/'.$_FILES['image1']['name'];
$newfile1 = Generate_Versioning_name($fname1);

$ori_thumb_image_names = explode('#',$newfile1);
$newfile1 = $ori_thumb_image_names[0];
$thumb_image = $ori_thumb_image_names[1];
//echo "<br>VIDEO ori : ".$newfile1."<br>VIDEO thum : ".$thumb_image;


$aaa = move_uploaded_file($ftmp1, $newfile1);

$cccccc = explode('.',$thumb_image);

$aa = Compress_Gen_Thumb_Image($newfile1,$thumb_image,$c ccccc[1]);

}
}



if(move_uploaded_file($ftmp, $newfile)){

if($filetype=='IMAGE')
{
$aa = Compress_Gen_Thumb_Image($newfile,$thumb_image,$ex t);
}

?>
<html><head>
<script type="text/javascript" src="ufo.js"></script>
<script>
var par = window.parent.document;
var images = par.getElementById('images');
var display_str = '';
var totalfiles='';
var filetypes='';
var filedescrips='';
var filecontimg='';
var ty='';


ty = '<? echo $filetype; ?>';

var FILES,TYPES,DESCS,CIMGs;

var i;
if(ty=='VIDEO')
{
window.parent.document.getElementById('files').val ue = window.parent.document.getElementById('files').val ue + "<? echo $newfile.'#'.$newfile1.'#temp/'.$thumb_image; ?>" + "~";
}
else
{
window.parent.document.getElementById('files').val ue = window.parent.document.getElementById('files').val ue + "<? echo $newfile.'#'.'temp/'.$thumb_image; ?>" + '~';
}

//window.parent.document.getElementById('files').val ue = window.parent.document.getElementById('files').val ue + '<? echo $newfile; ?>' + '~';

window.parent.document.getElementById('type').valu e = window.parent.document.getElementById('type').valu e + '<? echo $filetype; ?>' + '~';
window.parent.document.getElementById('file_desc') .value = window.parent.document.getElementById('file_desc') .value + window.parent.document.getElementById('edit[attach_desc]').value +'~';

//Ramesh added
window.parent.document.getElementById('edit[attach_desc]').value = '';
window.parent.document.getElementById('desc_char_c ount').innerHTML = '100';

totalfiles = window.parent.document.getElementById('files').val ue;
FILES = totalfiles.split('~');
filetypes = window.parent.document.getElementById('type').valu e;
TYPES = filetypes.split('~');
filedescrips = window.parent.document.getElementById('file_desc') .value;
DESCS = filedescrips.split('~');

display_str = '<DIV id="Total_Images_DIV" name="Total_Images_DIV" style="overflow:auto; width:850px; border:1px solid black; height:270px; display:block;">';
display_str += "<table border=0 width=10% height=100% cellpadding=0 cellspacing=0 valign=top><tr>";
for(i=0;i<TYPES.length-1;i++)
{
display_str += "<td valign=top><DIV valign=middle name='Table"+i+"' id='Table"+i+"' style='display:block;width:200px;height:250px;over flow:auto;'>";
display_str += "<table border=0 width=98% height=96% cellpadding=0 cellspacing=0 valign=top>";
display_str += "<tr height=1><td align=center><b>"+TYPES[i]+"</b></td></tr>";
if(TYPES[i]=='IMAGE')
{
var cccc = FILES[i].split('#');
display_str += "<tr height='100' valing='middle'><td align=center><input type=hidden id='main_hidd" + i + "' name='main_hidd" + i + "' value='0'><img src='" + cccc[1] + "' border=0></img></td></tr>";
}
if(TYPES[i]=='VIDEO')
{
display_str += "<tr height='100' valing='middle'><td align=center><input type=hidden id='main_hidd" + i + "' name='main_hidd" + i + "' value='0'>";
var ddd = FILES[i].split('#');
if(ddd[1]=='')
{
display_str += " <OBJECT codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' height='100' width='100' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>";
display_str += ' <param name="bgcolor" value="#FFFFFF" />';
display_str += ' <param name="flashvars" value="file=' + ddd[0] + '&image=preview.jpg&autostart=false&repeat=false&s howfsbutton=true" />';
display_str += ' <param name="allowfullscreen" value="true" />';
display_str += ' <param name="movie" value="flvplayer.swf" />';
display_str += ' </OBJECT>';
//display_str += "<img src='"+ddd[1]+"' border=0 width=100 height=100>";
}
else
{
display_str += "<img src='"+ddd[2]+"' border=0>";
}
display_str += "</td></tr>";
}
if(TYPES[i]=='AUDIO')
{
display_str += "<tr height='100'><td align=center><img src='images/audio.png' border=0 width=100 height=100></td></tr>";
}
display_str += "<tr height='100'><td name='file_desc" + i + "' id='file_desc" + i + "' align=left>" + DESCS[i] + "</td></tr>";
if ((TYPES[i]=='IMAGE')||(TYPES[i]=='VIDEO'))
{
display_str += "<tr height=1><td align=center><table border=0 width='180' cellpadding=0 cellspacing=0>";
display_str += "<tr>";
display_str += "<td align=left valign=middle style='WHITE-SPACE : nowrap;'>";

//Ramesh
// variable 'isFirstUpload' is required only for checking first time upload(if value is 1) it is always incrementing
// variable 'cont_images' is for apearing 'tick image' when delete (from this hidden variable,taking the value and comparing, if equal tick the image)
// number is concat with this bcz if the same filename exist 'comparing will confuse'
// variable 'whichIsTick' very important for geting no of images and for concat with files...

var isFu = window.parent.document.getElementById('isFirstUplo ad').value;
if(isFu == 1){
window.parent.document.getElementById('cont_images ').value = (i+1)+"~"+FILES[i];
//display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image &nbsp;</a></td><td name='make_main_image" + i + "' id='make_main_image" + i + "'><img border=0 src='images/make_main_img_flag.gif'></img>&nbsp;";
display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image &nbsp;</a></td><td name='make_main_image" + i + "' id='make_main_image" + i + "'><img border=0 src='images/make_main_img_flag1.gif'></img>&nbsp;";
}
else{
var mimg = window.parent.document.getElementById('cont_images ').value;
if(mimg==((i+1)+"~"+FILES[i])) {
//display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image &nbsp;</a></td><td name='make_main_image" + i + "' id='make_main_image" + i + "'><img border=0 src='images/make_main_img_flag.gif'></img>&nbsp;";
display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image &nbsp;</a></td><td name='make_main_image" + i + "' id='make_main_image" + i + "'><img border=0 src='images/make_main_img_flag1.gif'></img>&nbsp;";
}
else{
//display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image</a>&nbsp;</td><td name='make_main_image" + i + "' id='make_main_image" + i + "'></td>";
display_str += "&nbsp;&nbsp;<a href='#' onclick=\"PHP_MEDIA_make_main_image_link('" + i + "'); return false;\">Main Image</a>&nbsp;</td><td name='make_main_image" + i + "' id='make_main_image" + i + "'></td>";
}
}
//Ramesh
}
else
{
display_str += "<tr height=1><td><table border=0 width='180' cellpadding=0 cellspacing=0>";
display_str += "<tr>";
}

display_str += "<td align=center valign=middle style='WHITE-SPACE : nowrap;'>&nbsp;<a href='#' onclick=\"del_uploaded_files('" + i + "'); return false;\">Delete</a>&nbsp;</td>";
display_str += "<td align=center valign=middle style='WHITE-SPACE : nowrap;'>&nbsp;<a href='#' name='pos_right" + i + "' id='pos_right" + i + "' onclick=\"Open_EDIT_POPUP('total_table', 'Edit_File_Desc', '" + i + "'); return false;\">Edit</a>&nbsp;</td>";
display_str += "</tr></table>";
display_str += "</td></tr></table>";
display_str += "</DIV></td>";
}
display_str += "</tr></table></DIV>";
images.innerHTML = display_str;
//alert(display_str)
//par.getElementById('iframe').innerHTML ='';
par.getElementById('iframe').innerHTML ='<iframe src="upload.php" style="width:850px; height:120px;" frameborder="0" name="attach_frame" id="attach_frame"></iframe>'

//par.getElementById('_Confirm_buttons').style.displ ay = 'none';
//par.getElementById('_Upload_buttons').style.displa y = 'block';
</script>



</head>
</html>
<?php
exit();
}
?><html><head>
<link rel="stylesheet" href="themes/wakapa/style.css" type="text/css">

<script language="javascript">

function upload()
{
var fileurl='';;
var i;
var urllength;
var urllength1;
var revstr='',revstr1='';
var ext='',ext1='';
var revext='',revext1='';
var extlen,extlen1;
var FileDesc='';
var _errMsg='';

var par = window.parent.document;
var images = par.getElementById('images');
fileurl = document.getElementById('image0').value;
fileurl1 = document.getElementById('image1').value;
urllength = fileurl.length;
urllength1 = fileurl1.length;

if(fileurl1!='')
{
for(i=urllength1;i>=0;i--)
{
// reverse the thumbnail file path to get Extension
revstr1 = revstr1 + fileurl1.substring(i,i-1);
}
}
for(i=urllength;i>=0;i--)
{
// reverse the file path to get Extension
revstr = revstr + fileurl.substring(i,i-1);
}
// Get the extension in reverse format
revext = revstr.substring(0,(revstr.indexOf('.')));
revext1 = revstr1.substring(0,(revstr1.indexOf('.')));
// length of extension
extlen = revext.length;
extlen1 = revext1.length;

for(i=extlen;i>=0;i--)
{
// get the real extension from reversed format of ext.
ext = ext + revext.substring(i,i-1);
}
if(revext1!='')
{
for(i=extlen1;i>=0;i--)
{
// get the real extension from reversed format of ext.
ext1 = ext1 + revext1.substring(i,i-1);
}
}
FileDesc = window.parent.document.getElementById('edit[attach_desc]').value;


if((ext=='jpeg')||(ext=='jpg')||(ext=='gif')||(ext =='png')||(ext=='flv')||(ext=='mp3')||(ext=='JPEG' )||(ext=='JPG')||(ext=='GIF')||(ext=='PNG')||(ext= ='FLV')||(ext=='MP3'))
{
if((ext=='jpeg')||(ext=='jpg')||(ext=='gif')||(ext =='png')||(ext=='JPEG')||(ext=='JPG')||(ext=='GIF' )||(ext=='PNG'))
{
if(fileurl1!='')
{
_errMsg = "Images file won't need Thumbnail" + "\n";
}
}
if(ext=='flv')
{
/*if(fileurl1=='')
{
_errMsg = "Video file need Thumbnail image" + "\n";
}
else
{
if((ext1!='jpeg')&&(ext1!='jpg')&&(ext1!='gif')&&( ext1!='png')&&(ext1!='JPEG')&&(ext1!='JPG')&&(ext1 !='GIF')&&(ext1!='PNG'))
{
_errMsg = 'Video thumbnail must be the following file types:\nImages: jpg, jpeg and gif\nVideo: flv\nAudio: MP3\n\nPlease check the media type and try again. \n\n[OK]';
}
}*/
if(fileurl1!='')
{
if((ext1!='jpeg')&&(ext1!='jpg')&&(ext1!='gif')&&( ext1!='png')&&(ext1!='JPEG')&&(ext1!='JPG')&&(ext1 !='GIF')&&(ext1!='PNG'))
{
_errMsg = 'Video thumbnail must be the following file types:\nImages: jpg, jpeg and gif\nVideo: flv\nAudio: MP3\n\nPlease check the media type and try again. \n\n[OK]';
}
}
}
if(FileDesc=='')
{
_errMsg = 'Description is Empty...';
}
}
else
{
_errMsg = 'Media uploads must be the following file types:\nImages: jpg, jpeg and gif\nVideo: flv\nAudio: MP3\n\nPlease check the media type and try again. \n\n[OK]';
}






if(_errMsg=='')
{
//Ramesh added
var aa = parseInt(window.parent.document.getElementById('is FirstUpload').value);
var isFirstUpload = aa + 1;
window.parent.document.getElementById('isFirstUplo ad').value = isFirstUpload;

// hide old iframe


// add image progress

//var new_div = par.createElement('div');
//var new_img = par.createElement('img');
//new_img.src = 'indicator.gif';
//new_img.className = 'load';
//new_div.appendChild(new_img);
//images.appendChild(new_div);

// send
var imgnum = images.getElementsByTagName('div').length - 1;

document.iform.imgnum.value = imgnum;
setTimeout("document.iform.submit()",1000);

}
else
{
alert(_errMsg);
}
}
</script>

<form name="iform" id="iform" method="post" enctype="multipart/form-data">
<div class="form-item">
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td>
<p id="player"></p>
<label for="Attach file" style="font-size:13px;font-weight:bold;">File name (must be in jpg, jpeg, gif, mp3 or flv format)</label>
</td></tr>
<tr><td>
<input id="image0" type="file" style="width:600px;" name="image0" class="form-text"/><br>
</td></tr>
<tr><td>
<label for="Attach file" style="font-size:13px;font-weight:bold;">If this file is a video (FLV format), please also upload a thumbnail image for the video.<br/> Otherwise, the first frame of the video will be used</label>
</td></tr>
<tr><td>
<input id="image1" type="file" style="width:600px;" name="image1" class="form-text"/>
</td></tr>
</table>
<input type="hidden" name="imgnum" />
</div>
</form>

the above code is upload.php
-----------------------------------------------------
<div id="main" name="main" style="width:850px; height:120px;">
<!--<label for="Attach file" class="label_title_bold">Attach new file</label>-->
<div id="iframe" name="iframe" style="width:850px; height:120px;overflow:visible;display:block">
<iframe name="attach_frame" id="attach_frame" src="upload.php" style="width:850px; height:120px;" frameborder="0"></iframe>
</div>



<div class="form-item" name="_Confirm_buttons" id="_Confirm_buttons">
<input type="button" value="Add media" class="form-submit" onclick="attach_frame.upload();">
</div>


this is the area where i am adding images

plz can u help me in solving this problem
thanks
Ram
Sep 14 '07 #4
drhowarddrfine
7,435 Expert 4TB
The problem, as always, is IE. Your doctype is incomplete and throws IE into 'quirks mode'. You then designed your page using quirks and thought it would work in modern browsers. It won't.

In addition to that, there are 766 other html errors, possibly the worst I have ever seen. Until all those are fixed, I wouldn't expect modern browsers to ever display the page properly.
Sep 14 '07 #5

Post your reply

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

Similar topics

12 posts views Thread by wangzx | last post: by
reply views Thread by Chukka | last post: by
2 posts views Thread by Yanick | last post: by
12 posts views Thread by mistral | last post: by
5 posts views Thread by Chamnap | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.