blesseld Posted December 23, 2009 Share Posted December 23, 2009 Hey, I have been playing around with this... and it currently saves to the directory that this .php file is in. public_html->Course->Uploadfile.php So it's saving to Course folder, I want to create an uploads folder within "Course" and save the images there, I Tried researching move_uploaded_file but there is no clear way on changing the directory for the file destination. any help would be appreciated. if (isset($_POST['text'])) { $text = sanitizeString($_POST['text']); $text = preg_replace('/\s\s+/', ' ', $text); $query = "SELECT * FROM adccprofiles WHERE user='$user'"; if (mysql_num_rows(queryMysql($query))) { queryMysql("UPDATE adccprofiles SET text='$text' where user='$user'"); } else { $query = "INSERT INTO adccprofiles VALUES('$user', '$text')"; queryMysql($query); } } else { $query = "SELECT * FROM adccprofiles WHERE user='$user'"; $result = queryMysql($query); if (mysql_num_rows($result)) { $row = mysql_fetch_row($result); $text = stripslashes($row[1]); } else $text = ""; } $text = stripslashes(preg_replace('/\s\s+/', ' ', $text)); if (isset($_FILES['image']['name'])) { $saveto = "$user.jpg"; move_uploaded_file($_FILES['image']['tmp_name'], $saveto); $typeok = true; switch ($_FILES['image']['type']) { case "image/gif": $src = imagecreatefromgif($saveto); break; case "image/jpeg": // Both regular and progressive jpegs case "image/pjpeg": $src = imagecreatefromjpeg($saveto); break; case "image/png": $src = imagecreatefrompng($saveto); break; default: $typeok = false; break; } if ($typeok) { list($w, $h) = getimagesize($saveto); $max = 100; $tw = $w; $th = $h; if ($w > $h && $max < $w) { $th = $max / $w * $h; $tw = $max; } elseif ($h > $w && $max < $h) { $tw = $max / $h * $w; $th = $max; } elseif ($max < $w) { $tw = $th = $max; } $tmp = imagecreatetruecolor($tw, $th); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $tw, $th, $w, $h); imageconvolution($tmp, array( // Sharpen image array(-1, -1, -1), array(-1, 16, -1), array(-1, -1, -1)), 8, 0); imagejpeg($tmp, $saveto); imagedestroy($tmp); imagedestroy($src); } } echo "<br />"; showProfile($user); Link to comment https://forums.phpfreaks.com/topic/186156-uploading-images-working-but-need-to-change-save-location/ Share on other sites More sharing options...
ChemicalBliss Posted December 23, 2009 Share Posted December 23, 2009 Ok, so sounds liek u we're given a task, pray your teacher doesn't see this . I will give you a hint; You need to look at the "$saveto" variable. -CB- Link to comment https://forums.phpfreaks.com/topic/186156-uploading-images-working-but-need-to-change-save-location/#findComment-983120 Share on other sites More sharing options...
blesseld Posted December 23, 2009 Author Share Posted December 23, 2009 Haha, I'm actually not in school, already done I like a challenge, I'm just not a full on PHP programmer, more of a design xhtml/css guy making his way into programming. I'll give it another try and let ya know. Link to comment https://forums.phpfreaks.com/topic/186156-uploading-images-working-but-need-to-change-save-location/#findComment-983143 Share on other sites More sharing options...
blesseld Posted December 23, 2009 Author Share Posted December 23, 2009 Wow, easier than I thought, I don't know what i was trying the other day, but i somehow broke it, heh, the $user variable was throwing me off, thanks. Link to comment https://forums.phpfreaks.com/topic/186156-uploading-images-working-but-need-to-change-save-location/#findComment-983146 Share on other sites More sharing options...
ChemicalBliss Posted December 23, 2009 Share Posted December 23, 2009 np - it'll teach me to go in with pre-conceived notions lol! good on ya! -CB- Link to comment https://forums.phpfreaks.com/topic/186156-uploading-images-working-but-need-to-change-save-location/#findComment-983149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.