Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1

    Default Display and store image in php/mysql.. HELP!


    Maaung ud2.. patudlo tana ko unsaon di magdisplay ug image ug store ang image sa php/mysql. kanang magbrowse ka daan sa image na imu gus2 e store tapos display daun.. naa man tutorial ako gsunod sa phpacademy sa youtube.. pero ang gina hatag na image kay broken..

    <!--index.php na page-->

    <?php include_once 'mydb_connect.php';?><html>
    <head>
    <title>image upload</title>
    </head>
    <body>
    <form action = "index.php" method = "POST" enctype = "multipart/form-data">
    <label>File: <input type = "file" name = "image"/>
    <input type = "submit" value = "Upload"/></label>
    </form>
    <?php


    $file = @$_FILES['image']['tmp_name'];


    if(!isset($file)) {
    echo "Please select image";
    }
    else {
    $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
    $image_name = addslashes($_FILES['image']['name']);
    $image_size = getimagesize($_FILES['image']['tmp_name']);


    if($image_size == FALSE) {
    echo "Thats not an image!";
    }
    else {
    if(!$insert = mysql_query("INSERT INTO imageupload VALUES('','$image_name','$image')")) {
    echo "Problem Uploading Image";
    }
    else {
    $img_id = mysql_insert_id();
    echo "Image uploaded.<p/> Your image: <p /><img src=get_img.php?id=$img_id";
    }
    }
    }
    ?>
    </body>
    </html>

    <!--get_img.php na page-->

    <?php include_once 'mydb_connect.php';?>
    <?php
    $id = addslashes($_REQUEST['id']);
    $image = mysql_query("SELECT * FROM imageupload WHERE img_id = $id");
    $image = mysql_fetch_assoc($image);
    $image = $image['image'];
    header("Content-type: image/jpeg");
    echo $image;
    ?>

    -mao ni ang code..

    Salamat!

  2. #2
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465
    on pud imo gd library boss?

  3. #3
    activated man boss.. extension php_gd2.dll. nganu kaha ni b... Salamat di boss!

  4. #4
    Elite Member
    Join Date
    May 2011
    Gender
    Male
    Posts
    1,465
    break it down into two parts like i always do.
    1. try sa upload sa mysql lng sa then ipa.display sa php. if di mu.display, then problem in displaying
    2. dri naka mag.upload2x sa php then debug

    imo gi.pass ang image id dba?
    <qoute>
    echo "Image uploaded.<p/> Your image: <p /><img src=get_img.php?id=$img_id";
    </qoute>

    mass maau kung imo sad dawaton through calling $_GET [ 'id' ] boss. mao na ako cge buhaton. mugana man cya. try daw boss
    <qoute>
    <?php include_once 'mydb_connect.php';?>
    <?php
    if ( isset ( $_GET [ 'id' ] ) ) {
    $id = $_GET [ 'id' ];

    $image = mysql_query("SELECT * FROM imageupload WHERE img_id = $id");
    $image = mysql_fetch_assoc($image);
    $image = $image['image'];
    header("Content-type: image/jpeg");
    echo $image;
    }
    ?>
    </qoute>
    pwede wala ranang italic na line, kang if statement ba. try daw boss.

  5. #5
    payts kaau imu suggestion boss.. wala jud data na gka kuha.. nganu kaha ni.

  6. #6
    suwayi daw butang ug closing '>' kanang saimo <img> nga tag

  7. #7

  8. #8
    Pag codeigniter nalang bai. Dali ra kayo na.

  9. #9
    wala ghpon boss ondoy.. buak ghpon na image. sige boss chaos try nku karon.. ehehehe! dili pa kaau ko hanas ug php boss gina apply pa naku sa mga project namu karon.. sunod na ko anang codeigniter ehehee!

  10. #10
    bro,naa ny sulod imong database? if naa e try daw dritso saimo URL http://localhost/ur_project/get_img.php?id=Id_number

    din post diri unsy mo gawas

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Replies: 1
    Last Post: 11-15-2011, 11:49 AM
  2. help, im stuck! in PHP programming.
    By emailroy2002 in forum Programming
    Replies: 16
    Last Post: 07-08-2010, 11:43 PM
  3. Replies: 33
    Last Post: 10-17-2008, 04:09 PM
  4. Replies: 2
    Last Post: 11-06-2006, 01:29 PM
  5. Webhosting sites with PHP, MYSQL and etc
    By ravenclair3 in forum Websites & Multimedia
    Replies: 9
    Last Post: 08-13-2006, 10:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top