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 Link to comment https://forums.phpfreaks.com/topic/152146-get-image-size/ 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']."')"; ?> Link to comment https://forums.phpfreaks.com/topic/152146-get-image-size/#findComment-799057 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 Link to comment https://forums.phpfreaks.com/topic/152146-get-image-size/#findComment-799059 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() Link to comment https://forums.phpfreaks.com/topic/152146-get-image-size/#findComment-799065 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 Link to comment https://forums.phpfreaks.com/topic/152146-get-image-size/#findComment-799079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.