input_image.php

<p>metode image managementnya masih konstruksi</p><center>
      <p>


<?php

    include('../includes/koneksi.php');

    $id = isset($_POST['id']) ? $_POST['id'] : '';  
    $confirmation = isset($_POST['confirmation']) ? $_POST['confirmation'] : '';  
    $judul = isset($_POST['judul']) ? $_POST['judul'] : ''; 
    $image = isset($_POST['image']) ? $_POST['image'] : '';

    //Load berita
    if (!empty($_REQUEST['id'])){
        $result = mysql_query("SELECT * FROM gallery WHERE id =".$_REQUEST['id']) or die(mysql_error());
        $data = mysql_fetch_array($result);
        $id = $data['id'];
        $judul = $data['judul'];
        $image = $image['image'];

    }

    //Simpan berita 
    if (isset($_REQUEST['ok'])){

        if (empty($_REQUEST['id']))
            $sqlstr = "INSERT INTO gallery(judul, image) VALUES('".$judul."','".$image."')";
        else
            $sqlstr = "UPDATE gallery SET judul='".$judul."', image='".$image."' WHERE id=".$_REQUEST['id'];
        $result = mysql_query($sqlstr) or die(mysql_error());

            // cek type file & simpan file pada folder
            $file_exts = array("jpg", "bmp", "jpeg", "gif", "png");
            $upload_exts = end(explode(".", $_FILES["image"]["name"]));

            if ((($_FILES["image"]["type"] == "image/gif")
            || ($_FILES["image"]["type"] == "image/jpeg")
            || ($_FILES["image"]["type"] == "image/png")
            || ($_FILES["image"]["type"] == "image/pjpeg"))
            && ($_FILES["image"]["size"] < 2000000)
            && in_array($upload_exts, $file_exts))
                 {
            if ($_FILES["image"]["error"] > 0)
               {
               echo "Return Code: " . $_FILES["image"]["error"] . "<br>";
               } 
            else
               {
            echo "Upload: " . $_FILES["image"]["name"] . "<br>";
            echo "Type: " . $_FILES["image"]["type"] . "<br>";
            echo "Size: " . ($_FILES["image"]["size"] / 1024) . " kB<br>";   
            echo "Temp file: " . $_FILES["image"]["tmp_name"] . "<br>";
            // Enter your path to upload file here
            if (file_exists("c:\xampp\xampp\htdocs\rustoleum/photocms/" .
            $_FILES["image"]["name"]))
               {
               echo "<div class='error'>"."(".$_FILES["image"]["name"].")".
               " already exists. "."</div>";
               }
            else
              {
              move_uploaded_file($_FILES["image"]["tmp_name"],
              "c:\xampp\htdocs\free-prowebsite/site_pro/photos/" . $_FILES["image"]["name"]);
              echo "<div class='sucess'>"."Stored in: " .
              "c:\xampp\htdocs\free-prowebsite/site_pro/photos/" . $_FILES["image"]["name"]."</div>";
              }
               }
                }
            else
                {
                echo "<div class='error'>Invalid file</div>";
                }

        //Jika mode edit, maka tidak akan dikirimkan konfirmasi kepada subscriber
        //if (empty($_REQUEST['id']))   kirimEmail($idKategori, $judul, $news);
        $confirmation = ($result) ? "Data telah tersimpan." : "Gagal menyimpan data.";  
    }
    ?>
    <div align="center">
        <div style="width:800px;text-align:left;">
        <script type="text/javascript" src="../../Masterlink/cgoods/ckeditor/ckeditor.js"></script>
        <link href="../../Masterlink/cgoods/ckeditor/content.css" rel="stylesheet" type="text/css"/>
        <?php echo $confirmation;?>
        <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
            <input type="hidden" name="id" value="<?php echo $id; ?>"/>
            <table id="admintable" border="1" cellpadding="2" cellspacing="0">
                <tr>
                    <th>Judul</th>
                    <th>Image</th>
                </tr>
                <tr>
                    <td><input size="30px" type="text" name="judul" value="<?php echo $judul; ?>"/></td>
                </tr>
                <tr>
                    <td><input size="30px" type="file" name="image" value="<?php echo $image; ?>"/></td>
                </tr>
                <tr><?php // showing the picture ?>
                    <td><img src="../photos/<?php echo $image; ?>"/></td>
                </tr>                
                <tr>             
                    <td><input type="submit" name="ok" value="Simpan"/></td>
              </tr>
            </table>
        </form>
        </div>
    </div>

<?php 

    if(isset($image))echo "<div><img src=\"$imagepath\" alt=\"last uploaded image\" title=\"{$judul}\" height=\"100\" /><p>$imagepath</p></div>"; 

?>



metode image managementnya masih konstruksi


Notice: Undefined index: image in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 135

Notice: Undefined index: image in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 137

Notice: Undefined index: image in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 138

Notice: Undefined index: image in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 139

Notice: Undefined index: image in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 140
Invalid file
Data telah tersimpan.
Judul   Image

Notice: Undefined variable: imagepath in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 211

Notice: Undefined variable: imagepath in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 211
last uploaded image

----------------------------------------------

line 135 - 140:

        if ((($_FILES["image"]["type"] == "image/gif")
            || ($_FILES["image"]["type"] == "image/jpeg")
            || ($_FILES["image"]["type"] == "image/png")
            || ($_FILES["image"]["type"] == "image/pjpeg"))
            && ($_FILES["image"]["size"] < 2000000)

line 211:

Notice: Undefined variable: imagepath in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 211

Notice: Undefined variable: imagepath in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\input_image.php on line 211

How to fix the error? Also, why nothing happens. The files has not been copied to the new folder nor any file name record in the database (the file name record works in the beginning, I might have done something that makes it does not work now).

//Replace this path by

"c:\xampp\htdocs\free-prowebsite/site_pro/photos/"

//This


"c:/xampp/htdocs/free-prowebsite/site_pro/photos/"

//replace all the paths similar to this.I think this will work.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.