GD Library create multiple images

Discussion in 'PHP' started by aadi92s, Oct 1, 2011.

  1. #1
    hi,
    i am using GD Library and want to create multiple images
    But this code creat only 1 image
    My code is
    for($i=0;$i<3;$i++){ 
    
         
        $values = array( 
                    'event_name'    =>    "Disney On Ice presents DARE TO DREAM", 
                    'ticket_number'    =>    "0000008830", 
                    'event_date'    =>    date('Y-m-d'), 
                    'time'            =>    date('H:i'), 
                    'recipi'        =>    "John Smith", 
                    'state'         =>    "Amway Center", 
                    'address'        =>    "400 W Church Street", 
                    'city'             =>    "Orlando FL", 
                    'zip'             =>    "32805", 
                    'expire_date'    =>    "Friday, Sep. 30, 2011", 
                    'event_image'    =>    "ss", 
                    'ticket_type'    =>    "This is the ticket type", 
                    'ticket_price'    =>    "$25.00" 
                    ); 
                     
            $event_name        =    $values['event_name']; 
             
                 
            $width            =    800; 
            $height            =    436; 
         
            $arialbd        =    "arialbd.ttf"; 
            $arial            =    "arial.ttf"; 
                     
            $im        =    imagecreatefrompng("blankticket.png"); 
             
             
            $black    =    imagecolorallocate($im, 0, 0, 0); 
            $yellow    =    imagecolorallocate($im, 238, 175, 12); 
            $blue    =    imagecolorallocate($im, 1, 100, 165); 
             
            imagettftext($im, 10, 0, 583, 68, $black, $arialbd, $ticket_number); 
             
         
             
            header ("Content-type: image/png"); 
            imagepng($im, 'ticket.png'); 
            imagepng($im); 
             
            header('Content-Type: image/png'); 
            header('Content-Disposition: attachment;filename="ticket.png"'); 
            $fp=fopen('temp_ticket.png','r'); 
            fpassthru($fp); 
            fclose($fp); 
             
             
            } 
    PHP:

     
    aadi92s, Oct 1, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    I don't think it's possible to output more than one attachment.
    I suppose it's better to just create the tickets, and save them as images, and use javascript to redirect to all the files.
     
    ssmm987, Oct 1, 2011 IP
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    You cant send more than one attachment download.
    To juts output multiple files

    imagepng($im, "ticket{$i}.png");

    Then better is zip them and send single zip back to user.

    Hope it helps.
     
    Vooler, Oct 1, 2011 IP