SEO Software
Closed Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Images in database using php?

  1. #1

    Default Images in database using php?

    I want to store images in to database using php script. how to store it?


  2. SEO Software

  3. #2

    Default

    Which database you are using are you using mysql or other database please give more details abotu the database.

  4. #3

    Default

    Hi... Valendino...!!
    I am using Mysql Database....!!So, in Mysql how can we store images..!! Not path whole image...!!

  5. #4

    Default

    sample:


    if(isset($_POST['submit'])){
    $logos = $_POST['logo'];

    if($logos==""){
    $uploaddir ='../uploadPicture/header/';
    $filename = $_FILES['new_image']['name'];
    $uploadfile = $uploaddir . $filename;

    $extension = getExtension($filename);
    $extension = strtolower($extension);

    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
    {
    //print error message
    $errors= $lang['pic_error'][$ver];
    }
    else{

    $size=filesize($_FILES['new_image']['tmp_name']);

    if ($size > MAX_SIZE*1024)
    {
    $error1 = $lang['limit'][$ver];
    }
    else{

    if(move_uploaded_file($_FILES['new_image']['tmp_name'],$uploadfile))
    {

    echo " ";

    }else{
    echo $lang['cant_upload'][$ver];
    }

    $query = "insert into company_pic(company_pic) values('".$uploadfile."')";
    $result = mysql_query($query);
    }
    }
    }

    else{
    $uploaddir ='../uploadPicture/header/';
    $filename = $_FILES['new_image']['name'];
    $uploadfile = $uploaddir . $filename;

    $extension = getExtension($filename);
    $extension = strtolower($extension);

    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
    {
    //print error message
    $errors= $lang['pic_error'][$ver];
    }
    else{

    $size=filesize($_FILES['new_image']['tmp_name']);

    if ($size > MAX_SIZE*1024)
    {
    $error1 = $lang['limit'][$ver];
    }
    else{


    if(move_uploaded_file($_FILES['new_image']['tmp_name'],$uploadfile))
    {

    echo " ";

    }else{
    echo $lang['cant_upload'][$ver];
    }

    $query = "update company_pic set company_pic='".$uploadfile."' where id=$logos";
    $result = mysql_query($query);
    }
    }
    }
    }


    <form action="" method="post" enctype="multipart/form-data" id="something" class="uniForm">
    <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
    <input type="hidden" name="logo" value="<?=$logo_ids?>" />&nbsp;&nbsp;&nbsp;
    <INPUT type="reset" value="<?php echo $lang['reset'][$ver];?>">
    <button name="submit" type="submit" class="submitButton"><?php echo $lang["savethis"][$ver];?></button>
    </form>

  6. #5
    Fresh Meat Jamil is on a distinguished road
    Join Date
    Dec 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    good.............................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................

  7. #6

    Default

    Never store your images in a database this is terribly slow!!

  8. #7

    Default

    Its a bad bad bad idea to store images (or any files at that) directly into the database.

    Any reason why you want to do this?

  9. #8

  10. #9

    Default

    not all the time, if you want to save filespace anyways lol, anyways i'm not sure if mysql supports image compression or not, but you could put a huge varchar var on mysql that runs along the lines of:
    Code:
    width:5:height:5:#323423:#323423:#456375
    etc. of each pixel representing each hex color code. then from there you can create a fresh PHP image off of that data by exploding the delimiter ":", then cachoa you got yourself an image that you can easily load from mysql :P, I could create a tutorial on that as well if anyone wants me too

  11. #10
    Registered User immediate is on a distinguished road immediate's Avatar
    Join Date
    Nov 2009
    Location
    kavoir.com
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You need a blob field in binary in you MySQL database, then you can use a PHP script to read the image file with the file_get_contents() function and store the returned results in the blob field.
    So you want to start a website and get prevalent? How about purchasing some website content database.

Closed Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Can your SEO be helped by images?
    By Kay in forum SEO Forum
    Replies: 20
    Last Post: 04-23-2010, 04:27 AM
  2. Using Stock images
    By nikon in forum Legal Matters
    Replies: 7
    Last Post: 08-25-2009, 06:27 PM
  3. Vector Images
    By urvisoni in forum Graphics
    Replies: 12
    Last Post: 08-13-2009, 08:50 PM
  4. What type of Images?
    By nikon in forum Design and Development
    Replies: 16
    Last Post: 06-20-2009, 02:52 PM
  5. Stock Images
    By nikon in forum Legal Matters
    Replies: 5
    Last Post: 04-30-2009, 02:11 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts