dlouis95 Posted March 17, 2010 Share Posted March 17, 2010 First I would like to say hello because Im new here and new to php. I would like to take an image I've uploaded and save it as well as a thumbnail in two directory. Can you guys give the MOST basic code out there for this? Ill give the script I have already and the script that's working for me right now. My sites name is http://www.daniellsmith.com. The script I would like to add this code to is this: <?php // ============== // Configuration // ============== srand ((double) microtime( )*1000000); $random_number = rand(0,100000000); $uploaddir = "uploaded_files"; $uploadFilename=time().'_'.$random_number.".gif"; if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") or ($_FILES["file"]["type"] == "image/png")) { if ($_FILES["file"]["error"] > 0) { die("Error: " . $_FILES["file"]["error"] . "<br />"); } else { if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$uploadFilename); } } } else { die("Invalid file. Only Png Jpg and gif images are allowe to be posted on this site at this time."); } $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name2=$_POST['name2']; $email=$_POST['email']; $fileName=$uploadFilename; $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $datetime=date("m/d/y"); //create date time if($topic==null) { echo die("You did not put the pictures name!"); } if($name2==null) { echo die("You did not put your name!"); } if($email==null) { die("You didnt put your email! To get emails saying that you have gotton a comment, you need to put your real emial address."); } $sql="INSERT INTO $tbl_name(topic, detail, name2, email, datetime, file, ip)VALUES('$topic', '$detail', '$name2', '$email', '$datetime', '$fileName', '$ip')"; $result=mysql_query($sql); if($result){ header( 'Location: http://www.daniellsmith.com/index.php' ) ; } else { echo "ERROR"; } mysql_close(); ?> Thanks in advanced if you can help or can't. Quote Link to comment https://forums.phpfreaks.com/topic/195619-image-resizing/ Share on other sites More sharing options...
nafetski Posted March 17, 2010 Share Posted March 17, 2010 What is the script saying when you run it? Quote Link to comment https://forums.phpfreaks.com/topic/195619-image-resizing/#findComment-1027848 Share on other sites More sharing options...
dlouis95 Posted March 17, 2010 Author Share Posted March 17, 2010 What is the script saying when you run it? The script runs fine. I'm just trying to get some additional code so it will resize the image and save it to another directory. Ive tried several different things and have failed each time so I decided to get some personal help. Quote Link to comment https://forums.phpfreaks.com/topic/195619-image-resizing/#findComment-1027849 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.