contra10 Posted April 1, 2009 Share Posted April 1, 2009 don't really understand the getimagesize function basically i want to get the length and the width of the image before i put it into the db <?php if (isset($_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 = "INSERT INTO `images` (`type`, `image`, `userid`, `username`, `caption`, `city`) VALUES ('" . $fileType . "', '" . $data . "', '" . $id . "', '" . $name . "', '" . $caption . "', '" . $city . "')"; $results = mysql_query($query) or die(mysql_error()); ?> how do i place that in this code Quote Link to comment Share on other sites More sharing options...
WolfRage Posted April 1, 2009 Share Posted April 1, 2009 <?php $query = "INSERT INTO `images` (`type`, `image`, `userid`, `username`, `caption`, `city`,'size') VALUES ('" . $fileType . "', '" . $data . "', '" . $id . "', '" . $name . "', '" . $caption . "', '" . $city . ",".$_FILES['image']['size']."')"; ?> Quote Link to comment Share on other sites More sharing options...
contra10 Posted April 1, 2009 Author Share Posted April 1, 2009 sry, i meant like the length and the height, not the actual size Quote Link to comment Share on other sites More sharing options...
contra10 Posted April 1, 2009 Author Share Posted April 1, 2009 i want to put the length and width in th db <?php $caption = mysql_real_escape_string($_POST['caption']); $name = mysql_real_escape_string($_POST['usernamecookie']); $city = mysql_real_escape_string($_POST['city']); $file = mysql_real_escape_string($_FILES['image']); if (isset($_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); list($width, $height) = getimagesize($file); // Create the query and insert // into our database. $query = "INSERT INTO `images` (`type`, `image`, `length`, `width`,`userid`, `username`, `caption`, `city`) VALUES ('" . $fileType . "', '" . $data . "', '" . $width . "', '" . $height . "', '" . $id . "', '" . $name . "', '" . $caption . "', '" . $city . "')"; $results = mysql_query($query) or die(mysql_error()); // Print results print "Thank you, your file has been uploaded."; ?> trying to use the list() Quote Link to comment Share on other sites More sharing options...
contra10 Posted April 1, 2009 Author Share Posted April 1, 2009 could i resize after i take it out of db Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.