Activity Stream
48,167 MEMBERS
61122 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Member

    Default Please help me find a fix

    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?

    PHP Code: 
    <?
        
        
    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_y00$watermark_width$watermark_height100);  
                
    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>
    <?
                
    }
            }
        }
    ?>
    Help
    Divvy Reviewed by Divvy on . Please help me found a fix 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 Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Change the line:
    PHP Code: 
     $dt=date('Y/m/d'); 
    to :
    PHP Code: 
    $dt date('Y/m/d H:i:s'); 

  4.     
    #3
    Member
    Lock Down, thank you for your reply mate!
    Btw, I have two lines with the same code... I need to replace the 1st line? 2nd? or both?

    How about the image resize? Can you help me with that too?

  5.     
    #4
    Respected Member
    You are welcome. I would say to keep them the same change them both.

  6.     
    #5
    Member
    If the images are comming from a loop, you can add a class to the images and give it the following css atributes:

    Code: 
    .resize {
    width: 800px;
    height : auto;
    }
    
    .resize {
    width: auto;
    height : 800px;
    }

  7.     
    #6
    Member
    Website's:
    wautoposter.com
    Add this in you css

    Code: 
    img {
         width: 100%;
    }

    Code: 
    http://unstoppablerobotninja.com/entry/fluid-images
    use this for resize images

  8.     
    #7
    Respected Member
    Sorry I missed the part of making 800 the max width.

    change this :
    PHP Code: 
         $dest_x $size[0] - $watermark_width 2;  
         
    $dest_y $size[1] - $watermark_height 2
    to this:
    PHP Code: 
         if ($srcsize[0]>800){ $percent 800/$srcsize[0]; } else { $percent 1; }
         
    $dest_x = ($size[0]*$percent) - $watermark_width 2
         
    $dest_y = ($size[1]*$percent) - $watermark_width 2

  9.     
    #8
    Member
    Thank you for your replies mates

    Lock Down, I changed the date codes, but I think that doesn't work... I made an test upload, and saw my database table:
    http://screensnapr.com/e/sLTc8R.jpg

    Do I need to create a new field for time? If yes, how can I integrate that with my admin panel:
    http://screensnapr.com/e/ttnyly.jpg

    About the image resize, doesnt work either, the only thing that happened, was the watermark that moved place Take a look at the test upload image:
    http://www.boobsaroundtheworld.com/u...0610015253.jpg

    Anymore ideas?

  10.     
    #9
    Respected Member
    What size and type did you make for the date? It will hold both if it is correct size and type.

    ok for resize change this:
    PHP Code: 
                $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_y00$watermark_width$watermark_height100);  
                
    imagejpeg($image,$source_img); 
    to this:
    PHP Code: 
    $source_img=$dest;
    // Get new sizes
    list($width$height) = getimagesize($dest);
    if (
    $width>800) { $percent 800/$width; } else {$percent 1; }
    $newwidth $width $percent;
    $newheight $height $percent;
    // Load
    $source_img imagecreatetruecolor($newwidth$newheight);
    $source imagecreatefromjpeg($dest);
    // Resize
    imagecopyresized($source_img$source0000$newwidth$newheight$width$height);
    // Watermark
    $watermark imagecreatefrompng('logo.png');  
    $watermark_width imagesx($watermark);
    $watermark_height imagesy($watermark);    
    imagecopymerge($source_img$watermark$newwidth-$watermark_width-2,  $newheight-$watermark_height-200$watermark_width$watermark_height75); 
    imagejpeg($source_img); 

  11.     
    #10
    Member
    Lock Down, thank you for your reply mate!

    about the time issue, already fixed... I changed the database field from DATE to DATETIME

    about the resize, tried your code and didnt work... got some errors in background.
    but thats ok, I found a javascript to automaticly resize in my layout, and now looks fine.

    Thank you again Lock Down, and all who leaved here their tips

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 404 not found - cgi
    By xandor in forum Webmaster Discussion
    Replies: 4
    Last Post: 10th Feb 2012, 09:13 PM
  2. Found out i could have a kid
    By bmoeller in forum General Discussion
    Replies: 5
    Last Post: 25th May 2011, 06:25 AM
  3. Hello Just Found KWWH
    By Jeeny in forum Introductions
    Replies: 6
    Last Post: 3rd Mar 2011, 01:23 PM
  4. 404 Not found
    By SpiderZq in forum Server Management
    Replies: 8
    Last Post: 15th Sep 2009, 12:36 AM

Tags for this Thread

BE SOCIAL