- Forums - Reply - Statistics - Sign Up - Search -

The Wyzz WYSIWYG Editor / Coding Discussion / Upload your images now! - Image upload *done*
Author Message
Razon
Member
# Posted: 1 Jul 2009 01:19 - Edited by: Razon


With this "idea" of a modification, you could upload pictures!

First of all, you have to create a file called "upload.php" (just theoretical):

<html>
<head>
<title>Bild hochladen</title>
</head>
<?
if($_POST["submit"])
{
$dir = "yourdirectory/"; //directory your images should be uploaded to
$datei = $_FILES['upload']['tmp_name'];
$dateiname = $_FILES['upload']['name'];
$dateitype = $_FILES['upload']['type'];
switch($dateitype)
{
case "image/gif":
$types = ".gif";
break;

case "image/pjpeg":
$types = ".jpg";
break;

case "image/jpeg":
$types = ".jpg";
break;

case "image/x-png":
$types = ".png";
break;

default:
$types = false;
}
if (!file_exists($dir.$dateiname) && $types != false)
{
copy($datei,$dir.$dateiname);
echo '<script language="JavaScript">window.opener.insertHTML("<i mg src='.$dir.$dateiname.'>", "YOURFIELDID");self.close();</script>'; //DONT FORGET TO REPLACE "YOURFIELDID" with the id of your textfield!
}
else
{
echo "Die Datei ist bereits vorhanden oder es handelt sich nicht um eine Bilddatei!"; //Errormessage
}
}
else
{
echo '<form method="POST" enctype="multipart/form-data" action="upload.php"><p><input type="file" name="upload" size="20"></p><p><input type="submit" name="submit" value="Bild hochladen"></p></form>';
}
?>
</body>
</html>

DONT FORGET TO REPLACE "YOURFIELDID" with the id of your textfield and the directory your images should be uploaded to!

Then you have to edit "wyzz.js" (just theoretical):

Just should search for "function insertImage(n)" and replace the whole function with the following code (the function should begin with { and end with the next }):

function insertImage(n) {
window.open("upload.php","hochladen","width=400, height=100");
}

After uploading "wyzz.js" and "upload.php" to your server, you could enjoy the new function ;)

btw... the images should be directly inserted into the editor!

Darren Dignam
Member
# Posted: 14 Sep 2009 23:44


I have answered a differnt question in the forum with a method that lets you use imageshack.us as the online storage space for your images, and replace the popup dialogs (asking for image URL) with an image upload form, check it out:
http //www_wyzz_info/forum/index.php?action=vthread&for um=3&topic=57

I am new to posting here, and was unable to get all my code uploaded... but in these two posts you can checkout the technique:

theory:
http //blocsoft_com/blog/imageshack.asp
wyzz JS code:
http //blocsoft_com/blog/wyzz.asp

Your answer

Bold Style  Italic Style  Underlined Style  Image Link  URL Link  Disable BB codes *What's that?

 » Name  » Password 
 Only registered users can post here. Enter your login/password correctly before posting a message, or register first.
 

Powered by miniBB forum software © 2001-2010