becky155 Posted March 25, 2008 Share Posted March 25, 2008 Hi, I have been trying over and over again to create thumbnails and save them in a separate folder when the image is uploaded but I have not been successful. I am so, so frustrated! PLEASE, PLEASE if anyone can help me, I would really appreciate it. I have managed to write a program that successfully uploads the image to the server and saves a copy in my database but I am not sure what to do next. My upload code is: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Form")) { //This function separates the extension from the rest of the file name and returns it function findexts2 ($filename2) { $filename2 = strtolower($filename2) ; $exts2 = split("[/\\.]", $filename2) ; $n2 = count($exts2)-1; $exts2 = $exts2[$n2]; return $exts2; } function findexts2B ($filename2B) { $filename2B = strtolower($filename2B) ; $exts2B = split("[/\\.]", $filename2B) ; $n2B = count($exts2B)-1; $exts2B = $exts2B[$n2B]; return $exts2B; } //This applies the function to our file $ext2 = findexts2 ($_FILES['photo2']['name']); $ext2B = findexts2B ($_FILES['photo2B']['name']); //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran3 = rand () ; $ran3B = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran4 = $ran3."."; $ran4B = $ran3B."."; //Upload to the server $target = "/IMAGES/targetfile/"; $target2 = $target . $ran4.$ext2; $targetB2 = "IMAGES/targetfile/"; $target2B = $targetB2 . $ran4B.$ext2B; //This gets all the other information from the form $pic2 = $ran4.$ext2; $pic2B = $ran4B.$ext2B; //This checks if the file is a php file if ($pic2 =="text/php") { echo "No PHP files"; $ok=0; } if ($pic2B =="text/php") { echo "No PHP files"; $ok=0; } //Check file types if (($_FILES["photo2"]["type"] == "image/gif") || ($_FILES["photo2"]["type"] == "image/jpeg") || ($_FILES["photo2"]["type"] == "image/bmp") && ($_FILES["photo2"]["size"] < 30000)) if (($_FILES["photo2B"]["type"] == "image/gif") || ($_FILES["photo2B"]["type"] == "image/jpeg") || ($_FILES["photo2B"]["type"] == "image/bmp") && ($_FILES["photo2B"]["size"] < 30000)) { //Writes the photo to the server if (move_uploaded_file($_FILES['photo2']['tmp_name'], $target2)) if (move_uploaded_file($_FILES['photo2B']['tmp_name'], $target2B)) { $insertSQL = sprintf("INSERT INTO Database(Image, Image2) VALUES (%s, %s)", GetSQLValueString($pic2, "text"), GetSQLValueString($pic2B, "text"), mysql_select_db($database_database_name, $data_name); $Result1 = mysql_query($insertSQL, $database_name) or die(mysql_error()); $insertGoTo = "test.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } } } PLEASE, PLEASE, I NEED HELP ??? . THANKS IN ADVANCE! Link to comment https://forums.phpfreaks.com/topic/97733-pleaseneed-help-creating-thumbnail/ Share on other sites More sharing options...
lordfrikk Posted March 25, 2008 Share Posted March 25, 2008 What's the exact problem you're having? Don't know how to start or some different problem? Link to comment https://forums.phpfreaks.com/topic/97733-pleaseneed-help-creating-thumbnail/#findComment-500157 Share on other sites More sharing options...
xtrafile Posted March 25, 2008 Share Posted March 25, 2008 What I'd suggest doing is getting a thumbnail class and building off of that. It's a slightly complicated process, where you take the uploaded image, move it around to the thumbnail script, and returns that. In your case it'd be much easier to integrate a premade class. Link to comment https://forums.phpfreaks.com/topic/97733-pleaseneed-help-creating-thumbnail/#findComment-500249 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.