Pagina met een IFRAME en in die IFRAME een IFRAME
Ik heb een pagina script en laten we er vanuitgaan dat we op de index.php zitten.
IN die index.php heb ik een ifame die geladen is met: AJAX/index.php
AJAX/index.php:
-----------------------------------------
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<html>
<head>
<link href="../css/upload.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
<!--
function startUpload(){
document.getElementById('f1_upload_process').style.visibility = 'visible';
document.getElementById('f1_upload_form').style.visibility = 'hidden';
return true;
}
function stopUpload(success){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
//-->
</script>
</head>
<body>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<div id="container">
<div id="content">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
<td align="center"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
<td align="right"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
</tr>
</table>
</div>
<div id="content">
<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onSubmit="startUpload();" >
<p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p>
<p id="f1_upload_form" align="center"><br/>U kunt max. 3 foto's uploaden.<br>
<label>File: <input name="myfile" type="file" size="30" /></label>
<label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /></label>
</p>
</form>
</div>
</div>
</body>
</html>
<head>
<link href="../css/upload.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
<!--
function startUpload(){
document.getElementById('f1_upload_process').style.visibility = 'visible';
document.getElementById('f1_upload_form').style.visibility = 'hidden';
return true;
}
function stopUpload(success){
var result = '';
if (success == 1){
result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
}
else {
result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
}
document.getElementById('f1_upload_process').style.visibility = 'hidden';
document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
document.getElementById('f1_upload_form').style.visibility = 'visible';
return true;
}
//-->
</script>
</head>
<body>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<div id="container">
<div id="content">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
<td align="center"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
<td align="right"><img src="../images/geen_foto.jpg" width="100" height="100" alt="Foto 1" style="border:#000 1px dashed" /></td>
</tr>
</table>
</div>
<div id="content">
<form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onSubmit="startUpload();" >
<p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p>
<p id="f1_upload_form" align="center"><br/>U kunt max. 3 foto's uploaden.<br>
<label>File: <input name="myfile" type="file" size="30" /></label>
<label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /></label>
</p>
</form>
</div>
</div>
</body>
</html>
Nu gaat het formulier dus naar de UPLOAD.PHP
Upload.php:
--------------------------------------
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
// Edit upload location here
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$result = 0;
$target_path = $destination_path . basename( $_FILES['myfile']['name']);
if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
<script language="javascript" type="text/javascript">
window.top.window.stopUpload(<?php echo $result; ?>);
</script>
Nu is het de bedoeling dat de window.top.window.stopUpload weer geladen word in AJAX/index.php
Als je het bestand rechtstreeks benaderd dan werkt het.
Maar doe je het via de iframe op de standaard index....
Dan niet.
Wat moet hier veranderd worden??
Code (php)
1
2
3
4
2
3
4
<script language="javascript" type="text/javascript">
window.top.window.stopUpload(<?php echo $result; ?>);
</script>
Maar wat in je titel staat raad ik zeer zeker niet aan, zo en zo alles wat met frames te maken heeft, raad ik niet aan.
Je gebruikt nu window.top, je kan ook window.parent gebruiken in je binnenste iframe zal dit je 1e iframe terug geven.
Bedankt Boaz.... het werkt :$