Jump to content

[SOLVED] Image not saving into MySQL database


Bopo

Recommended Posts

Hi

 

Well I really don't know where to go from this, but basically I'm getting no errors, and the pages refreshes but there are never any new records, therefore it's not working, but I don't know what else to do

 

<?php

if(isset($_POST['submit'])) {

include ("blogconnect.php");

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);
      fclose($fp);
  
  $sql = "INSERT INTO userimage (image) VALUES ('$data')";
  $query = mysql_query($sql, $connect); 
  
  echo 'Your image has been uploaded!';

}
else
echo 'No image selected or uploaded';
}
?>

Many thanks for your help, everything seems to act exactly the same, however it's my form I believe could be the issue

 

					<form enctype="multipart/form-data" form id="form1" name="form1" method="post" action="" class="form">
<input name="MAX_FILE_SIZE" value="1002400" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<input value="Submit" type="submit">
</form>

 

I am checking that I'm only trying to upload a jpeg, and it's quite a small image, as I don't know the unit of measurement for the max file size value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.