www.webdeveloper.com
+ Reply to Thread
Page 23 of 23 FirstFirst ... 13 21 22 23
Results 331 to 339 of 339
  1. #331
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,722

  2. #332
    Join Date
    Jun 2012
    Posts
    4
    ok, I'll start a new thread. Forgot I had added an email notification in the upload.processor.php:

    $myfrom = $Email;
    $myemail = "name@emailaddress.com.au";
    $todayis = date("l, F j, Y, g:i a") ;
    $filename="http://www.webaddress.com.au/".$pathext.$_FILES['$fieldname']['name'].$OffExt;
    $filename=str_replace("","%20",$filename);

    $subject= "Request From Website";

    $message = "
    uploaded_files : $filename
    Name : $Name
    Email : $Email
    Phone : $Phone

    ";
    $from = "From: $myfrom\r\n";
    mail($myemail, $subject, $message, $from);

  3. #333
    Join Date
    May 2012
    Posts
    17
    Is there anybody who implement resize function for this code

  4. #334
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,722

  5. #335
    Join Date
    May 2012
    Posts
    17
    How do you want to resize?
    Great thanks for the code !

    The picture might be big on upload and i need to bring them to 800 x 600 pix and also will make them thambnail

    Thanks

  6. #336
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,722
    Something like this:
    PHP Code:
    function ResizeToAspectRatio($source$destination NULL$longside 800$as NULL)
    {
        
    $as $as?$as:4/3// default aspect ratio (4/3)
        
    $as = ($as 1) ? $as;
        
    $source_image = @file_get_contents($source)
            or die(
    'Could not open'.$source);
        
    $source_image = @imagecreatefromstring($source_image)
            or die(
    $source.' is not a valid image');
        
    $sw imagesx($source_image);
        
    $sh imagesy($source_image);
        if(
    $sw >= $sh)
        {
            
    $w $longside;
            
    $h $w / ($as);
            if((
    $sw/$sh)>($as))
            {
                
    $x2 $sh * ($as);
                
    $x1 = ($sw $x2)/2;
                
    $y1 0;
                
    $y2 $sh;
            }
            else
            {
                
    $x1 0;
                
    $x2 $sw;
                
    $y2 $sw / ($as);
                
    $y1 = ($sh $y2) / 2;
            }
        }
        else
        {
            
    $h $longside;
            
    $w $h / ($as);
            if((
    $sh/$sw)>($as))
            {
                
    $y2 $sw * ($as);
                
    $y1 = ($sh $y2)/2;
                
    $x1 0;
                
    $x2 $sw;
            }
            else
            {
                
    $y1 0;
                
    $y2 $sh;
                
    $x2 $sh / ($as);
                
    $x1 = ($sw $x2) / 2;
            }
        }
        
    $slate = @imagecreatetruecolor($w$h) or die('Invalid thumbnail dimmensions');
        
    imagecopyresampled($slate$source_image00$x1$y1$w$h$x2$y2);
        if(!
    $destinationheader('Content-type: image/jpeg');
        @
    imagejpeg($slate$destination100) or die('Directory permission problem');
        
    ImageDestroy($slate);
        
    ImageDestroy($source_image);
        if(!
    $destination) exit;
        return 
    true;


  7. #337
    Join Date
    Apr 2013
    Posts
    8
    Quote Originally Posted by bokeh View Post
    Something like this:
    PHP Code:
    function ResizeToAspectRatio($source$destination NULL$longside 800$as NULL)
    {
        
    $as $as?$as:4/3// default aspect ratio (4/3)
        
    $as = ($as 1) ? $as;
        
    $source_image = @file_get_contents($source)
            or die(
    'Could not open'.$source);
        
    $source_image = @imagecreatefromstring($source_image)
            or die(
    $source.' is not a valid image');
        
    $sw imagesx($source_image);
        
    $sh imagesy($source_image);
        if(
    $sw >= $sh)
        {
            
    $w $longside;
            
    $h $w / ($as);
            if((
    $sw/$sh)>($as))
            {
                
    $x2 $sh * ($as);
                
    $x1 = ($sw $x2)/2;
                
    $y1 0;
                
    $y2 $sh;
            }
            else
            {
                
    $x1 0;
                
    $x2 $sw;
                
    $y2 $sw / ($as);
                
    $y1 = ($sh $y2) / 2;
            }
        }
        else
        {
            
    $h $longside;
            
    $w $h / ($as);
            if((
    $sh/$sw)>($as))
            {
                
    $y2 $sw * ($as);
                
    $y1 = ($sh $y2)/2;
                
    $x1 0;
                
    $x2 $sw;
            }
            else
            {
                
    $y1 0;
                
    $y2 $sh;
                
    $x2 $sh / ($as);
                
    $x1 = ($sw $x2) / 2;
            }
        }
        
    $slate = @imagecreatetruecolor($w$h) or die('Invalid thumbnail dimmensions');
        
    imagecopyresampled($slate$source_image00$x1$y1$w$h$x2$y2);
        if(!
    $destinationheader('Content-type: image/jpeg');
        @
    imagejpeg($slate$destination100) or die('Directory permission problem');
        
    ImageDestroy($slate);
        
    ImageDestroy($source_image);
        if(!
    $destination) exit;
        return 
    true;


    Bokeh, your script is the best one I've seen anywhere. Thanks for offering it up for other people. I'm also impressed that 7 years later you are still answering questions to help people fit it into their requirements. Thanks!

    It works great on my local server (XAMMP) and on the serverwhere my personal website is hosted. Unfortunately, it does not work on my friends server where I am trying to install your image upload script to help him automate the process of adding profiles. Currently, he is using a simple HTML form I created several years ago that emails the user's entries to him for insertin into my template. His server is running PHP version 4.3 whereas my local and personal servers are running 5.3 versions. I've tried to figure out if that is the problem but have been unsuccessful. I have no access to the php.ini file on his server, for example. Are there any other things I should check to see why it would work on my two servers and not his?

    Bill

  8. #338
    Join Date
    Apr 2013
    Posts
    8
    And I forgot to add that I have not been able to integrate your resize code into your image upload script. I'm just beginning to learn PHP so it's probably a greenhorn mistake but any help would be appreciated. My eventual goal is to have the form for entering user information and the code for resizing and uploading images all in one script. Not sure that is possible but trying to make it happen will be a good learning exercise for me and a benefit to my friend if I get it working. Thanks Bokeh,

    Bill

  9. #339
    Join Date
    Jan 2005
    Location
    Alicante (Spain)
    Posts
    7,722
    Quote Originally Posted by qwertyportne View Post
    Are there any other things I should check to see why it would work on my two servers and not his?
    You need to start a new thread and post all your code. Switch on error reporting on the server that doesn't work. If it all works on you windows server but not on another it is probably a permissions thing.

Thread Information

Users Browsing this Thread

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

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles