tags:

views:

69

answers:

2

i have this page for upload:

<?php
require ('incs/db.php');
require_once ('incs/funcs.php');
?>

<?php


 if (array_key_exists('upload', $_POST)) {
         $directory = str_replace(basename($_SERVER['PHP_SELF']),'',$_SERVER['PHP_SELF']);
           $uploadHandler = $_SERVER['DOCUMENT_ROOT']. $directory . 'images/';
      //  $uploadHandler = "echtitipi".$_SERVER['HTTP_HOST']. '/images/';
                 $max_file_size = 30000;
         define('UPLOAD_DIR', $uploadHandler);
         $ext= end(explode(".",  $_FILES['image']['name']));
         $name = rand(1111111,9999999).'.'.$ext;   
                 if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadHandler. $name))
         {
             $upload = true;
             $title = $_POST ['title'];
             $sql = "INSERT INTO photo (id, keyword, photoName)
             VALUES ('','$title','$name')
             ";
            $result = mysql_query ( $sql, $con );
         }
         else
         {
             $upload = false;
             $msg = 'Cant Upload!';
         }
    }
?>
<?php

include ('incs/header.php');
?>
<?php

 getUrlQuery();

?>
<script language="javascript">
<!--

 function pick(symbol, path) {
  if (window.opener && !window.opener.closed)
    window.opener.document.form.img.value = symbol;
 window.opener.document.form.imgbox.src = path;
  window.close();
}

// -->
</script>
<form action="upload.php" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage">
            <p>
                <label for="image">
                    Tanım:
                </label>
                <input type="text" name="title" id="title" />
                <label for="image">
                    Upload image:
                </label>
                <input type="file" name="image" id="image" />
            </p>
            <p>
                <input type="submit" name="upload" id="upload" value="Upload" />
            </p>
        </form>
 <?php 
     if($upload == true)
     {
         echo "<a hrf(because spam!)=\"javascript:pick('$name','images/$name')\"><im(g) src=\"images/$name\" border=\"0\" alt=\"use\"></a>";
     }
 ?> 

    <?php
include ('incs/footer.php');
?>

`

this upload image to curretnt root's images folder. My current folder is admin:

root/admin/images

root/images

when i use

$uploadHandler = "http://".$_SERVER['HTTP_HOST']. '/images/';

script doesnot work.

<?php
if($upload == true)
{
echo "<a hrf=\"javascriptick('$name','{$uploadHandler}$name')\"><im(g) src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\"></a>";
}
?>

the image couldnot add to editor. I guess There is a problem with javascript. what is wrong in script

A: 
echo "<a hrf=\"javascriptick('$name','{$uploadHandler}$name')\"><im(g) src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\"></a>";

change into

echo "<a href=\"javascript('$name','{$uploadHandler}$name')\"><img src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\"></a>";

I guess this will help...

dfilkovi
For some reason, the entire question feels like a (badly-done) transcript of someone dictating..
K Prime
A: 

Im sorry for bad dictation because i cant write the right script because sending errors(link and images)

above code uploaded code to

/www/admin/images

and save information to database and add image to tinymce editor. But I want to upload code to:

www/images

when I use :

$uploadHandler = $_SERVER['DOCUMENT_ROOT'].'/images/';

and

"<a href=\"javascript:pick('$name','images/$name')\"><img src=\"images/$name\" border=\"0\" alt=\"use\"></a>"

the image couldnot add to editor. This is my problem.

You didn't mention anything about an editor. Are you using some sort of WYSIWYG interface?
Paul Lammertsma
in popup upload.php window, after uploadin appearing image below the form. when clicking this image drops in WYSIWYG editor.