htmlarea arbeitet meist mit showmodaldialog. hab ich ein eigenes script geschrieben. hier wird ein bild von der festplatte in der textarea angezeigt.
da das aber im www net funktionieren wird, will ich, dass das bild in einen ordner geuploaded wird.
das bild soll in einem neuen fenster geuploaden werden. mit showModalDialog funktioniert das nicht (da submit nicht in showModalDialog funktioniert), wenn ich das mit window.open versuche, hat er einen fehler mit window.dialogArguments.
hlp
PHP-Code:
<html STYLE="width: 432px; height: 168px; ">
<head><title>Bild einbinden</title><head>
<style>
html, body, button, div, input, select, td, fieldset { font-family: MS Shell Dlg; font-size: 8pt; };
</style>
<script>
// if we pass the "window" object as a argument and then set opener to
// equal that we can refer to dialogWindows and popupWindows the same way
opener = window.dialogArguments;
//var _editor_url = opener._editor_url;
var objname = location.search.substring(1,location.search.length);
//var config = opener.document.all[objname].config;
//var editor_obj = opener.document.all["_" +objname+ "_editor"];
//var editdoc = editor_obj.contentWindow.document;
/* alert( "opener: " + opener + "\n" +
"_editor_url: " + _editor_url + "\n" +
"objname: " + objname + "\n" +
"editor_obj: " + editor_obj + "\n" +
"editdoc: " + editdoc + "\n");
*/
function btnOKClick() {
//whatever
var whatever = "<img src=\"" + document.all.userfile.value + "\" border=\"1\" align=\"" + document.all.seite.value + "\" alt=\"bild\">";
// insert table
opener.editor_insertHTML(objname, whatever);
// close popup window
window.close();
}
</script>
</head>
<body>
Welches Bild? <input type="hidden" name="MAX_FILE_SIZE" value="50000"><input type="file" name="userfile"><br />
Links oder rechts? <select name="seite"><option value="left">Links</option><option value="right">Rechts</option></select>
<div style="left: 340px; top: 16px; position: absolute">
<BUTTON style="width: 7em; height: 2.2em; margin: 0 0 3 0" type="submit" onclick="btnOKClick()">OK</BUTTON><br>
<BUTTON style="width: 7em; height: 2.2em; " type=reset onClick="window.close();">Abbrechen</BUTTON>
</div>
</form>
</BODY>
</HTML>
PHP-Code:
<html STYLE="width: 432px; height: 168px; ">
<head><title>Bild einbinden</title><head>
<style>
html, body, button, div, input, select, td, fieldset { font-family: MS Shell Dlg; font-size: 8pt; };
</style>
<script>
// if we pass the "window" object as a argument and then set opener to
// equal that we can refer to dialogWindows and popupWindows the same way
opener = window.dialogArguments;
//var _editor_url = opener._editor_url;
var objname = location.search.substring(1,location.search.length);
//var config = opener.document.all[objname].config;
//var editor_obj = opener.document.all["_" +objname+ "_editor"];
//var editdoc = editor_obj.contentWindow.document;
/*alert( "opener: " + opener + "\n" +
"_editor_url: " + _editor_url + "\n" +
"objname: " + objname + "\n" +
"editor_obj: " + editor_obj + "\n" +
"editdoc: " + editdoc + "\n");*/
function btnOKClick() {
//whatever
var whatever = "<img src=\"bottom3.jpg\" border=\"1\" align=\"" + document.all.seite.value + "\" alt=\"bild\">";
// insert table
opener.editor_insertHTML(objname, whatever);
// close popup window
//window.close();
}
</script>
</head>
<body>
<?php
if(!isset($_POST['submit'])){
?>
<form enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>" method="POST">
Welches Bild? <input type="hidden" name="MAX_FILE_SIZE" value="50000"><input type="file" name="userfile"><br />
Links oder rechts? <select name="seite"><option value="left">Links</option><option value="right">Rechts</option></select>
<div style="left: 340px; top: 16px; position: absolute">
<BUTTON style="width: 7em; height: 2.2em; margin: 0 0 3 0" type="submit" name="submit">OK</BUTTON><br>
<BUTTON style="width: 7em; height: 2.2em; " type=reset onClick="window.close();">Abbrechen</BUTTON>
</div>
</form>
<?php
}else{
$bild_ordner = "news";
if(move_uploaded_file($_FILES['userfile']['tmp_name'], "../bilder/" . $bild_ordner . "/" . $_FILES['userfile'.$a]['name'])){
?>
<script type="text/javascript">
btnOKClick();
a = 3;
function countdown(){
document.write("Bild eingefügt! <br /> <b>" + a + "</b> Sekunden bis zum Schließen des Fensters");
a--;
}
window.setTimeout('countdown()',1000);
window.setTimeout('window.close()',3000);
</script>
<?php
$fehler=0;
}else{
echo "Fehler beim Uploaden<br />";
echo "Information über die Bilder: <br />";
echo "<pre>";
print_r($_FILES);
echo "</pre>";
}
}
?>
</BODY>
</HTML>
hlp