Witam czy mogłbym prosic o pomoc i nakierowanie jak przeorbic ten skrypt aby obrazki ktore sa dodawane nie traciły przezroczystości itp
<?php
include("../globals.php");
include("../db.php");
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header("Content-Type: text/html; charset=utf-8");
$main_folder="share/";
$folder = "images";
if ($_POST){
$file_name = $_FILES['thefile']['name'];
if($file_name){
$tmp_name = $_FILES['thefile']['tmp_name'];
$file_ext = substr($file_name,-3
); $file_type = $_FILES['thefile']['type'];
$allowed_ext = array('image/pjpeg','image/gif','image/jpeg');
// check file type is allowed
copy ($tmp_name, $file_name) or
die ("Error: could not copy file");
// if GD available, create thumbnail
if (function_exists('imagecreatetruecolor')) {
$new_height = (int) ((100 / $width) * $height);
$new_width = 100;
$image_p = imagecreatetruecolor($new_width,$new_height);
if ($file_type == "image/gif"){
$img = @imagecreatefromgif($file_name);
}else{
$img = @imagecreatefromjpeg($file_name);
}
imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
if ($file_type == "image/gif"){
imagegif($image_p,$folder."/".$file_name, 100);
}else{
imagejpeg($image_p,$folder."/".$file_name, 100);
}
}
// GD not unavailable, create duplicate image for thumbnail
else {copy ($tmp_name, $folder."/".$file_name) or
die ("Error: could not copy file");}
}
// image format not accepted
else{echo "Error: Image must be gif or jpeg/jpg";return
;}
}
// insert image into message table
if($file_name){
if($_POST['share_user']=='Enter Username' || !isset($_POST['share_user']) || !$_POST['all']){$_POST['share_user']='';}
$share_file = '<a href="'.$main_folder.'/'.$file_name.'" target="_blank"><img src="'.$main_folder.$folder.'/'.$file_name.'" border="0"></a>';
$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);
$sql = "INSERT INTO prochatrooms_share(user_name, share_file) VALUES ('".$_POST['chat_user']."', '".$file_name."')";mysql_query($sql);
}
// end of image options
}
?>