Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,576 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,890 people online right now. Registration is fast and FREE... Join Now!




image is not displaying...

 
Reply to this topicStart new topic

image is not displaying...

jlhon
2 Oct, 2008 - 07:08 PM
Post #1

New D.I.C Head
*

Joined: 2 Oct, 2008
Posts: 8

smile.gif
CODE

<?php
$submit=$_POST['submit'];
$cn = mysql_connect("localhost","root","");
mysql_select_db("db_image",$cn);

if($submit)
{
    $type = $_FILES['file']['type'];
    copy ($_FILES['file']['tmp_name'], "tmp/tmp.jpg") or die ("Could not copy");
    $filer="tmp/tmp.jpg";
    $handle = fopen($filer, "r");
    $pure = addslashes(fread($handle, filesize($filer)));
    $sql  = "insert into tbl_image(image,type) values('$pure','$type')";
    $result = mysql_query($sql,$cn)or die(mysql_error());
}

        $sql="SELECT * FROM tbl_image";
        $rst=mysql_query($sql) or die('gagal');
        while ($data=mysql_fetch_array($rst)){
            $id=$data[id];
            echo "picture no $id <a href='image.php?act=del&id=$id'>delete</a><br>";
             echo "<img src='tmp/image.php?act=view&id=$id'><br><br>";
            //echo $data[0];
            //echo $data[1];
            //echo $data[2];
            }
            


if ($act=='view'){
        $sql="SELECT * FROM tbl_image where id=$id";
        $rst=mysql_query($sql) or die('gagal');
        $data=mysql_fetch_array($rst);
        $type=$data[type];
        Header("Content-type: $type");
        echo $data[image];
    }
    
    if ($act=='del'){
        $sql="DELETE FROM tbl_image where id=$id";
        $rst=mysql_query($sql) or die('gagal');
    }    else{
    echo "yyuiuffgtytu";
    }

?>
<html>
<head>
<title>upload image</title>
</head>
<body>
<form action="<? echo $PHP_SELF;?>" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="submit">
</form>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Image Is Not Displaying...
2 Oct, 2008 - 07:26 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 3,995



Thanked: 16 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
you are echoing the images above your <html> tag, you should move the code into your body section or have a separate set of tags for the images.

Are you sure the images exist, have you checked the source that is generated to ensure the src is correct?

This post has been edited by William_Wilson: 2 Oct, 2008 - 07:27 PM
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Image Is Not Displaying...
3 Oct, 2008 - 12:17 AM
Post #3

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 396



Thanked: 37 times
Dream Kudos: 75
My Contributions
The fact that you posted the same query, in the same forum 3 times means I (along with others I'd imagine) won't be helping. Don't double (yet alone triple) post. Good luck though.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:10AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month