Jump to content

lukelee

Members
  • Posts

    92
  • Joined

  • Last visited

    Never

Everything posted by lukelee

  1. ah, it works, thanks man. What if I want to display the articles before 7days? can I write :" between 7 AND 100000"
  2. Hi, Currently I am making a module for joomla. every article has an publish date, if the article was published in 7 days ago, it will displayed as "article in last week", My idea is to use today's date - publish date, if the result is greater than 7 and smaller than 14, the article will be displayed as "article in last week. Any one know how to write this code? Here is what I have got, but not working. <?php $todays_date = date("Y-m-d"); $result = mysql_query("select * from jos_content where $test between $todays_date-14 and $todays_date-7"); while($row = mysql_fetch_array($result)) { echo "$todays_date - $row[title]"; } ?>
  3. I want to search a product, there is 2 selects, first one is category, second one is sub category. when people select a category, the sub category under this category will come out. does anyone know how to do this? <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <table border="0" class="catagory" > <tr><td><select name="firstlevel" style="width:180px;"> <option value="<?php echo $row['title']; ?>"><?php echo $row['title']; ?></option> </select></td> <td><select name="secondlevel" style="width:160px;"> <option value="<?php echo $row['sub_title']; ?>"><?php echo $row['sub_title']; ?></option> </select></td> <td><input type="submit" name="submit" id="submit" value="Submit" /></td> </tr> </table> </form>
  4. whats different between $password=$_POST['password']; and $password=$_POST[password]; seems both of them works. but which one is property?
  5. Hi, guys, I am making a simple shopping cart, now i got problem on check out function. i want to save the product information into database after click "checkout". because people may have different products in their shopping cart, so i made an array to display the items. but when I POST those items to next step which is check out, it only posts the latest item's information. can anyone help? thanks, here is a part of my code: function checkout() { $output[] = '<form action="checkout_process.php" method="post" id="cart">'; global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM product WHERE product_id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr><td><input type="hidden" name="model" value="'.$model.'"/></td>'; $output[] = '<td><input type="hidden" name="quantity'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td><input type="hidden" name="price" value="'.$price.'"/></td>'; $output[] = '<td><input type="hidden" name="price" value="'.($price * $qty).'"/></td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<div><button type="submit">check out</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); }
  6. I am trying to code a simple shopping cart but I am just a php starter and I have no idea how to save and edit the product information (price, quantity...) in the session and show the visitors what they have added into the shopping cart? anyone have any ideas? any simple lines of code gonna help, thanks
  7. I have made it, I put $htmpage=$_SERVER['HTTP_REFERER']; at the top, then <meta HTTP-EQUIV="REFRESH" CONTENT="3;URL=<? echo $htmpage; ?>"> thanks guys
  8. no, it doesnt work, and also i dont understand what is $page = (!empty($_SESSION['gPage']))?$_SESSION['gPage']:"index.php"; why do we put index.php here?
  9. here is my code: <?php session_start(); session_destroy(); $Login=$_POST['Login']; if($Login){ $username=$_POST['username']; $password=$_POST['password']; require_once('db.php'); $result=mysql_query("select * from member where username='$username' and password='$password'"); if(mysql_num_rows($result)!='0'){ session_register("username"); header("index.php"); exit; }else{ echo "Wrong username and password, back in 3 sec!"; } } ?> <meta http-equiv="Refresh" content="3; URL=index.php" > if the user is invalid, go to index.php, but if the user is valid, go to the previous page, I have login from in every page, so is there any codes to let you go back 1 page?
  10. I want to make a function: after you login, it auto go back to the previous page, does anyone know how to write the code?
  11. there is no serious error actually, its just a "out of memory" when i upload a large size image, like 2mb.
  12. I have also tried to use only 1 class, but the same problem still occurs, whats the most common way to make a thumbnail? i feel my way is not correct.
  13. I am using same instance for 5 times because people could upload 5 images at once, if people choose the same file for all 5 images, lets say the image is imageA, imageA will be saved as 1 thumbnail, 1 original image. And i have another function called delete image, people could choose 1 of 5 images to delete, one of the image deleted, the rest of 4 images will be "cant display image", because they are sharing 1 thumbnail, 1 original image.
  14. Hi, can you take a look at my code, how to delete the images from memory? and refine my code, I have tried, but didnt work. sorry, i am a nub on php. <?php require_once('db.php'); $title1 = $_POST['title1']; $title2 = $_POST['title2']; $title3 = $_POST['title3']; $title4 = $_POST['title4']; $title5 = $_POST['title5']; $file1 = $_FILES['ufile1']['name']; $file2 = $_FILES['ufile2']['name']; $file3 = $_FILES['ufile3']['name']; $file4 = $_FILES['ufile4']['name']; $file5 = $_FILES['ufile5']['name']; $filesize1=$_FILES['ufile1']['size']; $filesize2=$_FILES['ufile2']['size']; $filesize3=$_FILES['ufile3']['size']; $filesize4=$_FILES['ufile4']['size']; $filesize5=$_FILES['ufile5']['size']; class resizeimage1 { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage1($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo ""; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } class resizeimage2 { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage2($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo ""; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } class resizeimage3 { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage3($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo ""; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } class resizeimage4 { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage4($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo ""; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } class resizeimage5 { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage5($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo ""; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } $tempimgname1 = strtolower($_FILES["ufile1"][name]); $tempimgname1 = mb_convert_encoding( $tempimgname1, "gb2312", "utf-8"); $filesize1=$_FILES['ufile1']['size']; $tempimgname2 = strtolower($_FILES["ufile2"][name]); $tempimgname2 = mb_convert_encoding( $tempimgname2, "gb2312", "utf-8"); $filesize2=$_FILES['ufile2']['size']; $tempimgname3 = strtolower($_FILES["ufile3"][name]); $tempimgname3 = mb_convert_encoding( $tempimgname3, "gb2312", "utf-8"); $filesize3=$_FILES['ufile3']['size']; $tempimgname4 = strtolower($_FILES["ufile4"][name]); $tempimgname4 = mb_convert_encoding( $tempimgname4, "gb2312", "utf-8"); $filesize4=$_FILES['ufile4']['size']; $tempimgname5 = strtolower($_FILES["ufile5"][name]); $tempimgname5 = mb_convert_encoding( $tempimgname5, "gb2312", "utf-8"); $filesize5=$_FILES['ufile5']['size']; if($filesize1>0) { if(copy($_FILES["ufile1"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1))){ $image1 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class1 = new resizeimage1("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname1, 110, 110, 1); $s_image1 = basename($class1->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title1','$s_image1','$image1')"); imagedestroy($_FILES["ufile1"]["tmp_name"]); } } if($filesize2>0) { if(copy($_FILES["ufile2"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2))){ $image2 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class2 = new resizeimage2("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname2, 110, 110, 1); $s_image2 = basename($class2->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title2','$s_image2','$image2')"); imagedestroy($_FILES["ufile2"]["tmp_name"]); } } if($filesize3>0) { if(copy($_FILES["ufile3"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3))){ $image3 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class3 = new resizeimage3("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname3, 110, 110, 1); $s_image3 = basename($class3->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title3','$s_image3','$image3')"); imagedestroy($_FILES["ufile3"]["tmp_name"]); } } if($filesize4>0) { if(copy($_FILES["ufile4"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4))){ $image4 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class4 = new resizeimage4("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname4, 110, 110, 1); $s_image4 = basename($class4->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title4','$s_image4','$image4')"); imagedestroy($_FILES["ufile4"]["tmp_name"]); } } if($filesize5>0) { if(copy($_FILES["ufile5"]["tmp_name"],strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5))){ $image5 = basename(strtolower("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class5 = new resizeimage5("gallery/".date("Y-m-d-h-m-s",time()).$tempimgname5, 110, 110, 1); $s_image5 = basename($class5->dstimg); $query = mysql_query("INSERT INTO gallary(title, thumb, imagedata) VALUES ('$title5','$s_image5','$image5')"); imagedestroy($_FILES["ufile5"]["tmp_name"]); } } else { echo "You didn't pick any images." ; } ?>
  15. yeah, i got the same answer from another forum, can you please tell me how to delete the images and thumbnails from memory
  16. I think its a common problem, everyone needs a thumbnail function when make cms, isnt it? can someone help? tell me the best way to make a thumbnail function please!
  17. Hi, guys, i am making a cms to allow people upload 5 images at once, the problem is when the total size>1.3mb, "fetal error- out of memory" occurs. is there any way to avoid it? my memory limit is 64 and i cant change this number.
  18. this happens when the image is very large, but client often upload large images, i have to solve this problem.
  19. ok, my code is very long, its creating thumbnails and save into database. <?php require_once('db.php'); $address = $_POST[house_address]; $price = $_POST[price]; $bathroom = $_POST[bathroom]; $bedroom = $_POST[bedroom]; $garage = $_POST[garage]; $map = $_POST[map]; $description = $_POST[description]; class resizeimage { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo " !"; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); } } $tempimgname1 = strtolower($_FILES["image1"][name]); $tempimgname1 = mb_convert_encoding( $tempimgname1, "gb2312", "utf-8"); $filesize1=$_FILES['image1']['size']; $tempimgname2 = strtolower($_FILES["image2"][name]); $tempimgname2 = mb_convert_encoding( $tempimgname2, "gb2312", "utf-8"); $filesize2=$_FILES['image2']['size']; $tempimgname3 = strtolower($_FILES["image3"][name]); $tempimgname3 = mb_convert_encoding( $tempimgname3, "gb2312", "utf-8"); $filesize3=$_FILES['image3']['size']; $tempimgname4 = strtolower($_FILES["image4"][name]); $tempimgname4 = mb_convert_encoding( $tempimgname4, "gb2312", "utf-8"); $filesize4=$_FILES['image4']['size']; $tempimgname5 = strtolower($_FILES["image5"][name]); $tempimgname5 = mb_convert_encoding( $tempimgname5, "gb2312", "utf-8"); $filesize5=$_FILES['image5']['size']; if(($filesize1>0)&&($filesize2>0)&&($filesize3 ==0)&&($filesize4 ==0)&&($filesize5 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize3>0)&&($filesize4 ==0)&&($filesize5 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image3"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image3 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3, 150, 150, 1); $s_image3 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','3','$s_image3','$image3','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize4>0)&& ($filesize3 ==0)&& ($filesize5 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image4 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4, 150, 150, 1); $s_image4 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','4','$s_image4','$image4','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize5>0) && ($filesize3 ==0) && ($filesize4 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image5 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5, 150, 150, 1); $s_image5 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','5','$s_image5','$image5','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize3>0)&&($filesize4 >0)&& ($filesize5 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image3 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3, 150, 150, 1); $s_image3 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','3','$s_image3','$image3','$description')"); $image4 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4, 150, 150, 1); $s_image4 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','4','$s_image4','$image4','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize3>0)&&($filesize5 >0)&& ($filesize4 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image3 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3, 150, 150, 1); $s_image3 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','3','$s_image3','$image3','$description')"); $image5 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5, 150, 150, 1); $s_image5 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','5','$s_image5','$image5','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize4>0)&&($filesize5 >0)&& ($filesize3 ==0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image4 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4, 150, 150, 1); $s_image4 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','4','$s_image4','$image4','$description')"); $image5 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5, 150, 150, 1); $s_image5 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','5','$s_image5','$image5','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else if(($filesize1>0)&&($filesize2>0)&&($filesize3>0)&&($filesize4>0)&& ($filesize5>0)) { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)) && copy($_FILES["image2"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)) && copy($_FILES["image4"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname1, 260, 260, 1); $s_image1 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','1','$s_image1','$image1','$description')"); $image2 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname2, 150, 150, 1); $s_image2 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','2','$s_image2','$image2','$description')"); $image3 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname3, 150, 150, 1); $s_image3 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','3','$s_image3','$image3','$description')"); $image4 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname4, 150, 150, 1); $s_image4 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','4','$s_image4','$image4','$description')"); $image5 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname5, 150, 150, 1); $s_image5 = basename($class->dstimg); $query = mysql_query("insert into house (title,address,price,bedroom,bathroom,garage,map,thumb,imagedata1,imagedata,description) values ('house','$address','$price','$bedroom','$bathroom','$garage','$map','5','$s_image5','$image5','$description')"); echo "Image has been edited, will go back to previous page in 3 sencond"; } } else { echo "You can't leave the first or second image empty." ; } ?> <meta http-equiv="Refresh" content="3; URL=http://www.propertyw1.com.au/admin_add_new.php" > (edited to add tags)
  20. guys, i always got this message: Fatal error: Out of memory (allocated ..... i heared this is php bug, but how to solve this problem? my server information is: Hosting package Advance w Full access Server Name intrigue cPanel Version 11.23.6-STABLE cPanel Build 27698 Theme x3 Apache version 2.2.10 (Unix) PHP version 5.2.8 MySQL version 5.0.51a-community Architecture i686 Operating system Linux
  21. Now I can save both thumbnail and original image into folder, but i can only save the original image name into database. I think the problem is thumbnail code is within a class, and 'insert into' is outside of the class, see the red line. can anyone help me with that? <?php require_once('db.php'); $address = $_POST[house_address]; class resizeimage { var $type; var $width; var $height; var $resize_width; var $resize_height; var $cut; var $srcimg; var $dstimg; var $im; function resizeimage($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); echo " !"; } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); echo " "; } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_small.".$this->type; $new_small = basename($this->dstimg); echo "Image has been edited, will go back to previous page in 3 sencond"; } } $tempimgname = strtolower($_FILES["image1"][name]); $tempimgname = mb_convert_encoding( $tempimgname, "gb2312", "utf-8"); $tmpfiletype = substr(strrchr($tempimgname,"."),1); if($tmpfiletype=="jpg" || $tmpfiletype=="gif" || $tmpfiletype=="png") { if(copy($_FILES["image1"]["tmp_name"],strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname))) { $image1 = basename(strtolower("upload/".date("Y-m-d-h-m-s",time()).$tempimgname)); $class = new resizeimage("upload/".date("Y-m-d-h-m-s",time()).$tempimgname, 260, 260, 1); $query = mysql_query("insert into house (address,thumb,imagedata1,imagedata) values ('$address','1','$new_small','$image1')"); } else { echo "Upload failed"."<br>"; } } else { echo "image only allows jpg,gif,png"; } ?>
  22. I am making an image upload function, when people submit an image, it will be auto resized, and save both resized image(thumbnail) and original image into folder which is on the server, and save the modified image name into database, which is 'imagedata1' and 'imagedata'. these codes are from someone google, it works fine, except it couldnt save the resized image(thumbnail) into database.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.