binary data manipulation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shailajaAdiga
    New Member
    • Nov 2007
    • 8

    #1

    binary data manipulation

    Hi All..

    I am new to php programming. I know how to insert and delete images in database. But I would like to know how we can modify the existed image. i.e. already image is stored in databse. Now i have to change that image say for the same user. I have tried this with UPDATE. But its taking time to load new image. I have to refresh the page many times to display changed image.

    Is there any other method to modify?

    Thanking all


    Shailaja
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by shailajaAdiga
    Hi All..

    I am new to php programming. I know how to insert and delete images in database. But I would like to know how we can modify the existed image. i.e. already image is stored in databse. Now i have to change that image say for the same user. I have tried this with UPDATE. But its taking time to load new image. I have to refresh the page many times to display changed image.

    Is there any other method to modify?

    Thanking all


    Shailaja
    Perhaps the delay is something to do with the code you are using for the connection and the manner in which you are updating the image.
    Without seeing the code no one can tell what the problem is, so post the code you are using.

    Comment

    • shailajaAdiga
      New Member
      • Nov 2007
      • 8

      #3
      Originally posted by r035198x
      Perhaps the delay is something to do with the code you are using for the connection and the manner in which you are updating the image.
      Without seeing the code no one can tell what the problem is, so post the code you are using.
      Thank you for your reply...
      ......Here is the code to update image
      [code=php]
      # change the image
      if (isset($_POST['change_image'])){
      $image_id = $_POST['image_id'];

      $imageUpload = $_FILES['image_2_upload ']["tmp_name"];
      $imageUpload_na me = $_FILES['image_2_upload ']['name'];
      $imageUpload_ty pe = $_FILES['image_2_upload ']['type'];
      $imageUpload_si ze = $_FILES['image_2_upload ']['size'];

      # check file was uploaded via HTTP POST
      if (is_uploaded_fi le($imageUpload )) {
      $imageHandle = fopen($imageUpl oad, "r");
      $imageContent = fread($imageHan dle, $imageUpload_si ze);
      $imageContent = addslashes($ima geContent);

      $sql = "UPDATE organization_lo gos SET image = '{$imageContent }' ,image_type= '{$imageUpload_ type}' WHERE image_id = '{$image_id}' ";
      $result = mysql_query($sq l) or die(mysql_error ());
      $num = mysql_affected_ rows();
      if ($num) {
      header ("Location: logo_actions.ph p?changed=yes&o rg_id={$org_id} ");
      }
      } # end if (is_uploaded_fi le($imageUpload ))
      else {
      header ("Location: logo_actions.ph p?changed=no&or g_id={$org_id}" );
      }
      } # end if (isset($_POST['change']))


      database connection..(in clude file)

      <?php # Connections/web_user.php
      /* ---------------------------------------------------------------- */
      # general web user connection

      /* ---------------------------------------------------------------- */
      $hostname = "localhost" ;
      $username = "webuser";
      $password = "sdg7234";
      $db_conn = mysql_connect($ hostname, $username, $password) or die(error_messa ge("dbconnect_e rror"));
      ?>
      [/code]
      In main file...
      [code=php]
      mysql_select_db ('authenticatio n');
      [/code]

      Thank you very much..
      Last edited by Atli; Nov 9 '07, 01:23 PM. Reason: Added [code] tags.

      Comment

      Working...