Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Przezroczystość alpha
Forum PHP.pl > Forum > Przedszkole
dave666
Witam czy mogłbym prosic o pomoc i nakierowanie jak przeorbic ten skrypt aby obrazki ktore sa dodawane nie traciły przezroczystości itp
  1. <?php
  2. include("../globals.php");
  3. include("../db.php");
  4.  
  5. header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
  6. header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
  7. header( "Cache-Control: no-cache, must-revalidate" );
  8. header( "Pragma: no-cache" );
  9. header("Content-Type: text/html; charset=utf-8");
  10.  
  11. $main_folder="share/";
  12. $folder = "images";
  13.  
  14. if ($_POST){
  15.  
  16. $file_name = $_FILES['thefile']['name'];
  17.  
  18. if($file_name){
  19.  
  20. $userimg = ereg_replace (" ", "_", md5(date("U")));
  21. $tmp_name = $_FILES['thefile']['tmp_name'];
  22. $file_ext = substr($file_name,-3);
  23. $file_name = $userimg.".".strtolower($file_ext);
  24. $file_type = $_FILES['thefile']['type'];
  25. $allowed_ext = array('image/pjpeg','image/gif','image/jpeg');
  26.  
  27. // check file type is allowed
  28.  
  29. if(in_array($file_type, $allowed_ext)){
  30.  
  31. copy ($tmp_name, $file_name) or die ("Error: could not copy file");
  32.  
  33. // if GD available, create thumbnail
  34.  
  35. if (function_exists('imagecreatetruecolor')) {
  36.  
  37. list($width, $height) = getimagesize($file_name);
  38. $new_height = (int) ((100 / $width) * $height);
  39. $new_width = 100;
  40.  
  41. $image_p = imagecreatetruecolor($new_width,$new_height);
  42.  
  43. if ($file_type == "image/gif"){
  44. $img = @imagecreatefromgif($file_name);
  45. }else{
  46. $img = @imagecreatefromjpeg($file_name);
  47. }
  48.  
  49. imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  50.  
  51. if ($file_type == "image/gif"){
  52. imagegif($image_p,$folder."/".$file_name, 100);
  53. }else{
  54. imagejpeg($image_p,$folder."/".$file_name, 100);
  55. }
  56.  
  57. }
  58.  
  59. // GD not unavailable, create duplicate image for thumbnail
  60.  
  61. else {copy ($tmp_name, $folder."/".$file_name) or die ("Error: could not copy file");}
  62.  
  63. }
  64.  
  65. // image format not accepted
  66.  
  67. else{echo "Error: Image must be gif or jpeg/jpg";return;}
  68.  
  69. }
  70.  
  71. // insert image into message table
  72.  
  73. if($file_name){
  74.  
  75. if($_POST['share_user']=='Enter Username' || !isset($_POST['share_user']) || !$_POST['all']){$_POST['share_user']='';}
  76.  
  77. $share_file = '<a href="'.$main_folder.'/'.$file_name.'" target="_blank"><img src="'.$main_folder.$folder.'/'.$file_name.'" border="0"></a>';
  78.  
  79. $sql = "INSERT INTO prochatrooms_message(chat_id, avatar, user_id, user_name, to_user_name, room, message, approved, post_time) VALUES ('1', 'share.gif', '".$_POST['chat_userid']."', '".$_POST['chat_user']."', '".$_POST['share_user']."', '".$_POST['room']."', '".$share_file."', 'yes', NOW())";mysql_query($sql);
  80.  
  81. $sql = "INSERT INTO prochatrooms_share(user_name, share_file) VALUES ('".$_POST['chat_user']."', '".$file_name."')";mysql_query($sql);
  82.  
  83. }
  84.  
  85. // end of image options
  86.  
  87. }
  88.  
  89. ?>
wookieb
http://forum.php.pl/index.php?showtopic=11...st&p=568619
Dla gifów jest odwrotna kolejnosc true, false
dave666
Super dzięki to na pewno pomoże tylko trochę potrwa zanim domyśle się jak to połączyć a raczej zamienić tak zeby działało wszystko elegancko trochę nad tym posiedzę i cos na pewno wyjdzie
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.