Please help me found a fix

Discussion in 'PHP' started by Divvy, Jun 9, 2011.

  1. #1
    Hello my friends,

    Im here to request your help fixing 2 littleee things :)
    I have an upload page in my website, where my users can send their photos directly to my website. But I need to fix this:

    1- When someone uploads a big photo, the image brokes my layout...
    I need to automatically resize the uploaded image with a limit of 800px width. It is possible in the code below? How?

    2- When they send the photos, the date will be saved in my database, but I need also the time... It is possible in the code below? How?

    <?
       
        include("library/globals.php");
        $dbc=mysql_connect($host,$username,$password) or die('Unable to connect to the database...');
        mysql_select_db($dbname) or die('Unable to select the database...');
       
        if(isset($_POST['submt']))
        {
            $name=$_POST['name'];
            $country=$_POST['country'];
            $email=$_POST['email'];
            $picture=$_FILES['picture']['name'];
            $comment=$_POST['comment'];
               
            $arr=explode('.',$picture);
            $img=date('ymdhis').".".$arr[1];
            $dest="uploaded/".$img;
            $dt=date('Y/m/d');
            $cur_dt=date('Y-m-d');
            $val1=move_uploaded_file($_FILES['picture']['tmp_name'],$dest);
            if($val1)
            {
                $source_img=$dest;
                $watermark = imagecreatefrompng('images/logo.png'); 
                $watermark_width = imagesx($watermark);
                $watermark_height = imagesy($watermark);
                $image = imagecreatetruecolor($watermark_width, $watermark_height); 
                $image = imagecreatefromjpeg($source_img); 
                $size = getimagesize($source_img); 
                $dest_x = $size[0] - $watermark_width - 2; 
                $dest_y = $size[1] - $watermark_height - 2; 
                imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); 
                imagejpeg($image,$source_img);
                   
                $qry="insert into thon_post (`name`,`picture`,`country_name`,`dt`,`email`,`comment`,`start_date`) values('$name','$img','$country','$dt','$email','$comment','$cur_dt')";
                $rs=mysql_query($qry);
                $val2=mysql_insert_id();
                $dt=date('Y/m/d');
                $str=$val2."%%".$dt."%%http://www.thongsaroundtheworld.com/conteudo/p.php?id=".$val2."%%0%%\n";
                $fp=fopen('ccount/clicks.txt',"a");
                fwrite($fp,$str);
                fclose($fp);
                if($val2>0)
                {
    ?>
                    <script language="javascript" type="text/javascript">
                        alert('Congratulations! Your request is successfully looged in our server.\nWhen we will approve it, it will be displayed in our website.');
                        //window.location.href='upload.php';
                        window.close();
                    </script>
    <?
                }
            }
        }
    ?>
    PHP:
    Help :)
     
    Divvy, Jun 9, 2011 IP
  2. phppro9x

    phppro9x Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. You need write function Resize image
     
    phppro9x, Jun 9, 2011 IP
  3. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Can you help me with that? :)
     
    Divvy, Jun 9, 2011 IP