Closed Thread
Page 5 of 5 FirstFirst ... 345
Results 41 to 48 of 48

Thread: Tutorial: Storing Images in MySQL with PHP

  1. #41
    Join Date
    Aug 2009
    Location
    ~/
    Posts
    918
    Rep Power
    19

    Re: Tutorial: Storing Images in MySQL with PHP

    Just saw this for the first time...
    Great tutorial +rep

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #42
    phillw's Avatar
    phillw is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Northwest England (UK)
    Posts
    82
    Blog Entries
    1
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    Quote Originally Posted by ezcat View Post
    Need some education. I looked around but didn't find an answer I understood or it doesn't matter anyway.

    On this line:
    <input name="image" accept="image/jpg" type="file">

    My question is; what does accept="image/jpg" do for me? I can use this same code to upload jpg or pdf files. Should I worry about this to upload different file types?

    Thanks,
    Jon
    I'm not too sure on the uploading of file types - but you do need to declare the mime type for them to display correctly.

    Or, at least that's my understanding of the subject. If you declare a mime type of jpg and output a pdf file - it won't display correctly.
    If anyone knows different, please correct me.

    Phill.

  4. #43
    ezcat is offline Learning Programmer
    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    I do understand that you need the correct mime type to display the image.

    My question is for uploading the image.

    Jon

  5. #44
    scumbogs is offline Newbie
    Join Date
    Jan 2010
    Posts
    5
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    Cant wait in the nest tutorial i relly nid this tutorial for our proposal project in schools

  6. #45
    frozie's Avatar
    frozie is offline Newbie
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    This is my code
    Code:
    <?php
    require_once("startsession.php");
    include_once(
    "mysql.php");
    $database "binary";
    ?>
    <form enctype="multipart/form-data" action="" method="post" name="changer">
    <input name="MAX_FILE_SIZE" value="102400" type="hidden">
    <input name="image" accept="image/jpeg" type="file">
    <input value="Submit" type="submit">
    <?php

    // Make the connect to MySQL or die
    // and display an error.
    $link mysql_connect($host$username$password);
    if (!
    $link) {
        die(
    'Could not connect: ' mysql_error());
    }

    // Select your database
    mysql_select_db ($database);  


    if (isset(
    $_FILES['image']) && $_FILES['image']['size'] > 0) { 

          
    // Temporary file name stored on the server
          
    $tmpName  $_FILES['image']['tmp_name'];  
           
          
    // Read the file 
          
    $fp      fopen($tmpName'r');
          
    $data fread($fpfilesize($tmpName));
          
    $data addslashes($data);
          
    fclose($fp);
          

          
    // Create the query and insert
          // into our database.
          
    $query "INSERT INTO tbl_images ";
          
    $query .= "(image) VALUES ('$data')";
          
    $results mysql_query($query$link);
          
          
    // Print results
          
    print "Thank you, your file has been uploaded.";
          
    }
    else {
       print 
    "No image selected/uploaded";
    }

    // Close our MySQL Link
    mysql_close($link);
    ?>
    But in the database or the images/jpeg dot show image or anything in the database

  7. #46
    raman_di is offline Newbie
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    Hi!,

    I am looking for the full script of image into database and show in php.After lot of searches I found your script which is working till ad.html and image into mysql.The real problem is like it is only showing show.php as Please select your image!.

    I am not understanding where did the error occur.i even downloaded you script and tried the same thing is what it says.Please do help me its urgent for me for a portal I am doing where I need to upload images for each person registering and displaying their details.


    Thanks and Regards,
    Ram.

  8. #47
    bobmacans is offline Newbie
    Join Date
    Jun 2010
    Posts
    8
    Rep Power
    0

    Re: Tutorial: Storing Images in MySQL with PHP

    This will be of great help to people. You have done a great job.

  9. #48
    Join Date
    Jun 2010
    Location
    USA
    Posts
    579
    Blog Entries
    6
    Rep Power
    20

    Re: Tutorial: Storing Images in MySQL with PHP

    The original poster is no longer with CodeCall. If you have any question regarding this posting, please start a new thread in the appropriate section of the forum (and reference this thread).

    Thank you.
    Wrap [Code] tags when posting code by click on
    Before posting your question, did you look here?

Closed Thread
Page 5 of 5 FirstFirst ... 345

Thread Information

Users Browsing this Thread

There are currently 7 users browsing this thread. (0 members and 7 guests)

Similar Threads

  1. storing images in database
    By ravi951 in forum Database & Database Programming
    Replies: 6
    Last Post: 08-21-2011, 03:11 PM
  2. Replies: 213
    Last Post: 04-14-2011, 07:57 PM
  3. Beginner Storing images in XML file - Part II - Displaying image
    By Jaan in forum PHP Tutorials
    Replies: 6
    Last Post: 01-04-2011, 08:35 PM
  4. storing and load images using linq to sql
    By aglayo2010 in forum C# Programming
    Replies: 0
    Last Post: 09-25-2010, 08:40 PM
  5. Replies: 2
    Last Post: 07-16-2009, 12:48 PM

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