Jump to content

[SOLVED] can't update image


contra10

Recommended Posts

i'm having trouble updating an image in my db.

my code is as follows

 

<?php 

include('settings.php'); 
// Make sure the user actually 
// selected and uploaded a file

if(isset($_COOKIE['ID_my_site'])) 
{ 
$usernamecookie = $_COOKIE['ID_my_site']; 
}

if(is_numeric($_GET['user'])){

$id = $_GET['user'];
}

$name = mysql_real_escape_string($_POST['usernamecookie']);
$idpic = mysql_real_escape_string($_POST['iduser']);

if (isset($_POST['submit']) && ($_FILES['image']) && $_FILES['image']['size'] > 0) { 
  
  // Temporary file name stored on the server
      $tmpName  = $_FILES['image']['tmp_name']; 
  $fileType = $_FILES['image']['type'];
      
  
  // Read the file 
      $fp   = fopen($tmpName, 'r');
      $data = fread($fp, filesize($tmpName));
      $data = addslashes($data);
      fclose($fp);
      

      // Create the query and insert
      // into our database.
      $query = "UPDATE `tbl_images` SET `image` = '" . $data . "', `filetype` = '" . $fileType . "' WHERE `userid` = '" . $idpic . "'";
      $results = mysql_query($query) or die(mysql_error());
      
      // Print results
      print "Thank you, your file has been uploaded.";
  
  }else{
	  echo "no photo uploaded";

}
// Close our MySQL Link
mysql_close($link);
?>

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="changer">
<input name="MAX_FILE_SIZE" value="512000000000" type="hidden">
<input name="image" accept="image/jpeg" type="file">
<tr><td><?php echo "<input type='hidden' name='usernamecookie' value='$usernamecookie'>"?></tr></td>
<tr><td><?php echo "<input type='hidden' name='iduser' value='$id'>"?></td>
<input value="Submit" type="submit" name="submit">

Link to comment
https://forums.phpfreaks.com/topic/151448-solved-cant-update-image/
Share on other sites

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.