1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Rep Power

    Increasing Image Size

    Hi! I have a two basic extension file for Uploading and Inserting Image in MySQL. First I have a ADD.HTML File & Second INSERT.PHP, ADD.HTML provide form input box for image upload, it goes as below:



    <head><title>Form upload to DataBase</title>



    <form enctype="multipart/form-data" action="insert.php" 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">




    Second, I have INSERT.PHP to insert image to MySQL Database, which code is as below:



    // Create MySQL login values and

    // set them to your login information.

    $username = "root";

    $password = "****** ";

    $host = "localhost";

    $database = "binary";

    // 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);

    // Make sure the user actually

    // selected and uploaded a file

    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($fp, filesize($tmpName));

    $data = addslashes($data);


    // 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.";




    print "No image selected/uploaded";


    // Close our MySQL Link



    Everything is right, i can upload image to my binary database with table tbl_images, but i can only upload image of size <= 58.7 KB & when i upload image with size 223 KB it display message as:

    No image selected/uploaded

    How to increase image size in above code? Please help me! i'm in dilemma.
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Rep Power
    try this one :

    // Create a blank image and add some text
    $im = imagecreatetruecolor(120, 20);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);

    // Save the image as 'simpletext.jpg'
    imagejpeg($im, 'simpletext.jpg');

    // Free up memory

    Comments on this post

    • ManiacDan disagrees : How is this at all relevant?
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power
    the maximum file upload size is a setting in php.ini, check that.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Rep Power
    you also have this:

    <input name="MAX_FILE_SIZE" value="102400" type="hidden">

    102400 = bytes which google suggests is 100KB.. so you have placed this limit there yourself. Increase it accordingly and see what happens.

    ALSO there is a $_FILES['image']['error'] echo it out and it will tell you the REAL problem. (check the php manual for the right "code")

    FInally, do not store image in the database.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Rep Power
    Thanks! guys.

IMN logo majestic logo threadwatch logo seochat tools logo