I am trying following script for uploading image but their is nothing happen or no error message. Please help me... Here is my code... ########################### <?php //session_start(); //Include database connection details require_once('../connection/config.php'); $teacher_id=$_GET['id']; echo "$teacher_id"; $image_tempname = $_FILES['image_filename']['name']; $today = date("d-m-Y"); //upload image and check for image type $ImageDir ="images_dir/"; //**INSERT THIS LINE: $ImageThumb = $ImageDir . "thumbs/"; //**END OF INSERT $ImageName = $ImageDir . $image_tempname; if (move_uploaded_file($_FILES['image_filename']['tmp_name'], $ImageName)) { //get info about the image being uploaded list($width, $height, $type, $attr) = getimagesize($ImageName); //**insert these new lines if ($type > 3) { echo "Sorry, but the file you uploaded was not a GIF, JPG, or " . "PNG file.<br>"; echo "Please hit your browser's 'back' button and try again."; } else { //image is acceptable; ok to proceed //**end of inserted lines //insert info into image table $sql = "INSERT INTO `teacher_image` (id,teacher_ID,image_name,date) VALUES ('','$teacher_id','','$today')"; $insertresults = mysql_query($sql ) or die(mysql_error()); $lastpicid = $teacher_id; //change the following line: $newfilename = $ImageDir . $lastpicid . ".jpg"; //**insert these lines if ($type == 2) { rename($ImageName, $newfilename); } else { if ($type == 1) { $image_old = imagecreatefromgif($ImageName); } elseif ($type == 3) { $image_old = imagecreatefrompng($ImageName); } //"convert" the image to jpg $image_jpg = imagecreatetruecolor($width, $height); imagecopyresampled($image_jpg, $image_old, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg($image_jpg, $newfilename); imagedestroy($image_old); imagedestroy($image_jpg); } //**INSERT THESE LINES $newthumbname = $ImageThumb . $lastpicid . ".jpg"; //get the dimensions for the thumbnail //$thumb_width = $width * 0.10; //$thumb_height = $height * 0.10; $thumb_width = 80; $thumb_height = 80; //create the thumbnail $largeimage = imagecreatefromjpeg($newfilename); $thumb = imagecreatetruecolor($thumb_width, $thumb_height); imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height); imagejpeg($thumb, $newthumbname); imagedestroy($largeimage); imagedestroy($thumb); //**END OF INSERT //$url = "location: showimage.php?id=" . $lastpicid; //header($url); //**end of inserted lines echo("<font color = red><b>Image Has been Added Successfully! </b>"); } } ?> ###############################
i want o know wht adding the date of img in the database why why is there is no server to doing that? you can just save the files name in the database and save the img file in the server you can use any thing of these http://www.jooria.com/projects/view?project=983 http://www.jooria.com/projects/view?project=981 http://www.jooria.com/projects/view?project=980 http://www.jooria.com/projects/view?project=944 http://www.jooria.com/projects/view?project=965 http://www.jooria.com/projects/view?project=982
Hello, Thanks for your reply. I want this automatically to upload in server and ata the same time add data to the database because i want to develop a school management software. Please help me Thanks
Did you make sure the upload folders are set to CH777 and that you GD support enabled on your php setup?