Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2011, 05:36
Avatar de ivangd
ivangd
 
Fecha de Ingreso: febrero-2010
Mensajes: 28
Antigüedad: 14 años, 2 meses
Puntos: 0
Header con JPEG

Buenas a todos,

Iré al grano, llevo tiempo intentando que un archivo .php sea leído por el servidor como un .jpg ó .png para que así la gente pueda guardarlo como imagen... pero todos mis esfuerzos han sido en vano.

El .php se encarga de recibir una serie de valores de un formulario y en función de que halla seleccionado la gente muestra o no una serie de imágenes (es para una firma)

Os pego el código integro.

Código PHP:
<?php
ob_start
();

//ini_set('display_errors','0');



$nick=$_POST['nick'];
$graduacion=$_POST['rango'];

$mision=$_POST['misionesoficiales'];

$honor=$_POST['honor'];
$servicios=$_POST['servicios'];
$estrella_plata=$_POST['estrella_plata'];
$orosalva=$_POST['orosalva'];
$platasalva=$_POST['platasalva'];
$estrella_bronce=$_POST['estrella_bronce'];
$drojo=$_POST['drojo'];
$damarillo=$_POST['damarillo'];

$infanteria=$_POST['infanteria'];
$medico=$_POST['heridos'];
$granadero=$_POST['granadero'];
$ametrallador=$_POST['ametrallador'];
$tirador=$_POST['tirador'];
$anticarro=$_POST['anticarro'];
$zapador=$_POST['zapador'];
$ligeros=$_POST['ligeros'];
$carros=$_POST['carros'];
$aereas=$_POST['helicopteros'];
$aerotransportada=$_POST['aerotransportada'];
$radio=$_POST['radio'];

$firma='';

$firma.="<table id='base'>
  <tr>
    <td width='180' height='90' class='medallas'>
        "
;
        if(
$honor=='si')
                
$firma.="<img src='medalla/honor.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$servicios=='si')
                
$firma.="<img src='medalla/distinguidos.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$estrella_plata=='si')
                
$firma.="<img src='medalla/estrellaplata.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$orosalva=='si')
                
$firma.="<img src='medalla/cruzoro.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
    
$firma.="</td>
    <td width='70' align='center' class='graduacion'>"
;
        if(
$graduacion=='alferez')
                
$firma.="<img src='graduacion/alferez.png'>";
        
f($graduacion=='cabo1')
                
$firma.="<img src='graduacion/cabo1.png'>";
        if(
$graduacion=='cabo')
                
$firma.="<img src='graduacion/cabo.png'>";
        if(
$graduacion=='cabo_mayor')
                
$firma.="<img src='graduacion/cabomayor.png'>";
        if(
$graduacion=='capitan')
                
$firma.="<img src='graduacion/capitan.png'>";
        if(
$graduacion=='comandante')
                
$firma.="<img src='graduacion/comandante.png'>";
        if(
$graduacion=='sargento1')
                
$firma.="<img src='graduacion/sargento1.png'>";
        if(
$graduacion=='sargento')
                
$firma.="<img src='graduacion/sargento.png'>";
        if(
$graduacion=='soldado1')
                
$firma.="<img src='graduacion/soldado1.png'>";
        if(
$graduacion=='soldado')
                
$firma.="<img src='graduacion/soldado.png'>";
        if(
$graduacion=='suboficial_mayor')
                
$firma.="<img src='graduacion/suboficialmayor.png'>";
        if(
$graduacion=='subteniente')
                
$firma.="<img src='graduacion/subteniente.png'>";
        if(
$graduacion=='teniente')
                
$firma.="<img src='graduacion/teniente.png'>";
        if(
$graduacion=='teniente_coronel')
                
$firma.="<img src='graduacion/tenientecoronel.png'>";
    
    
$firma.="</td>
    <td width='360' class='nombre'>"
;
    
    
$texto $nick
$maximo strlen($texto); 
$ultima='0';

for (
$i=0;$i<$maximo;$i++){ 

    if(
$texto{$i}=='a' or $texto{$i}=='A')
        
$firma.="<img src='letras/A.png'>"
    if(
$texto{$i}=='b' or $texto{$i}=='B')
        
$firma.="<img src='letras/B.png'>"
    if(
$texto{$i}=='c' or $texto{$i}=='C')
        
$firma.="<img src='letras/C.png'>"
    if(
$texto{$i}=='d' or $texto{$i}=='D')
        
$firma.="<img src='letras/D.png'>";
    if(
$texto{$i}=='e' or $texto{$i}=='E')
        
$firma.="<img src='letras/E.png'>"
    if(
$texto{$i}=='f' or $texto{$i}=='F')
        
$firma.="<img src='letras/F.png'>"
    if(
$texto{$i}=='g' or $texto{$i}=='G')
        
$firma.="<img src='letras/G.png'>"
    if(
$texto{$i}=='h' or $texto{$i}=='H')
        
$firma.="<img src='letras/H.png'>"
    if(
$texto{$i}=='i' or $texto{$i}=='I')
        
$firma.="<img src='letras/I.png'>"
    if(
$texto{$i}=='j' or $texto{$i}=='J')
        
$firma.="<img src='letras/J.png'>"
    if(
$texto{$i}=='k' or $texto{$i}=='K')
        
$firma.="<img src='letras/K.png'>"
    if(
$texto{$i}=='l' or $texto{$i}=='L')
        
$firma.="<img src='letras/L.png'>"
    if(
$texto{$i}=='m' or $texto{$i}=='M')
        
$firma.="<img src='letras/M.png'>"
    if(
$texto{$i}=='n' or $texto{$i}=='N')
        
$firma.="<img src='letras/N.png'>"
    if(
$texto{$i}=='o' or $texto{$i}=='O')
        
$firma.="<img src='letras/O.png'>"
    if(
$texto{$i}=='p' or $texto{$i}=='P')
        
$firma.="<img src='letras/P.png'>"
    if(
$texto{$i}=='q' or $texto{$i}=='Q')
        
$firma.="<img src='letras/Q.png'>"
    if(
$texto{$i}=='r' or $texto{$i}=='R')
        
$firma.="<img src='letras/R.png'>"
    if(
$texto{$i}=='s' or $texto{$i}=='S')
        
$firma.="<img src='letras/S.png'>"
    if(
$texto{$i}=='t' or $texto{$i}=='T')
        
$firma.="<img src='letras/T.png'>"
    if(
$texto{$i}=='u' or $texto{$i}=='U')
        
$firma.="<img src='letras/U.png'>"
    if(
$texto{$i}=='v' or $texto{$i}=='V')
        
$firma.="<img src='letras/V.png'>"
    if(
$texto{$i}=='w' or $texto{$i}=='W')
        
$firma.="<img src='letras/W.png'>"
    if(
$texto{$i}=='x' or $texto{$i}=='X')
        
$firma.="<img src='letras/X.png'>"
    if(
$texto{$i}=='y' or $texto{$i}=='Y')
        
$firma.="<img src='letras/Y.png'>"
    if(
$texto{$i}=='z' or $texto{$i}=='Z')
        
$firma.="<img src='letras/Z.png'>"

}  
    
        
    
$firma.="</td>
   <td width='70' align='center' class='graduacion'>"
;

        if(
$graduacion=='alferez')
                
$firma.="<img src='graduacion/alferez.png'>";
        
f($graduacion=='cabo1')
                
$firma.="<img src='graduacion/cabo1.png'>";
        if(
$graduacion=='cabo')
                
$firma.="<img src='graduacion/cabo.png'>";
        if(
$graduacion=='cabo_mayor')
                
$firma.="<img src='graduacion/cabomayor.png'>";
        if(
$graduacion=='capitan')
                
$firma.="<img src='graduacion/capitan.png'>";
        if(
$graduacion=='comandante')
                
$firma.="<img src='graduacion/comandante.png'>";
        if(
$graduacion=='sargento1')
                
$firma.="<img src='graduacion/sargento1.png'>";
        if(
$graduacion=='sargento')
                
$firma.="<img src='graduacion/sargento.png'>";
        if(
$graduacion=='soldado1')
                
$firma.="<img src='graduacion/soldado1.png'>";
        if(
$graduacion=='soldado')
                
$firma.="<img src='graduacion/soldado.png'>";
        if(
$graduacion=='suboficial_mayor')
                
$firma.="<img src='graduacion/suboficialmayor.png'>";
        if(
$graduacion=='subteniente')
                
$firma.="<img src='graduacion/subteniente.png'>";
        if(
$graduacion=='teniente')
                
$firma.="<img src='graduacion/teniente.png'>";
        if(
$graduacion=='teniente_coronel')
                
$firma.="<img src='graduacion/tenientecoronel.png'>";
    
    
$firma.="</td>
    <td width='180' class='medallas'>"
;
     
        if(
$platasalva=='si')
                
$firma.="<img src='medalla/cruzplata.png'>";    
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$estrella_bronce=='si')
                
$firma.="<img src='medalla/estrellabronce.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$drojo=='si')
                
$firma.="<img src='medalla/distintivorojo.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        if(
$damarillo=='si')
                
$firma.="<img src='medalla/distintivoamarillo.png'>";
            else
                
$firma.="<img src='medalla/blank.png'>";
        
    
$firma.="</td>
  </tr>
  <tr>
    <td colspan='5' height='110' class='metopas' align='center'>"
;
                
        if(
$medico=='heridos_oro')
                
$firma.="<img src='metopa/medico/oro.png'>";    
        if(
$medico=='heridos_plata')
                
$firma.="<img src='metopa/medico/plata.png'>";
        if(
$medico=='heridos_bronce')
                
$firma.="<img src='metopa/medico/bronce.png'>";
        
        if(
$granadero=='granadero_oro')
                
$firma.="<img src='metopa/granadero/oro.png'>";
        if(
$granadero=='granadero_plata')
                
$firma.="<img src='metopa/granadero/plata.png'>";
        if(
$granadero=='granadero_bronce')
                
$firma.="<img src='metopa/granadero/bronce.png'>";
        
        if(
$ametrallador=='ametrallador_oro')
                
$firma.="<img src='metopa/ametrallador/oro.png'>";
        if(
$ametrallador=='ametrallador_plata')
                
$firma.="<img src='metopa/ametrallador/plata.png'>";
        if(
$ametrallador=='ametrallador_bronce')
                
$firma.="<img src='metopa/ametrallador/bronce.png'>";
        
        if(
$tirador=='tirador_oro')
                
$firma.="<img src='metopa/tirador/oro.png'>";
        if(
$tirador=='tirador_plata')
                
$firma.="<img src='metopa/tirador/plata.png'>";
        if(
$tirador=='tirador_bronce')
                
$firma.="<img src='metopa/tirador/bronce.png'>";
        
        if(
$anticarro=='anticarro_oro')
                
$firma.="<img src='metopa/anticarro/oro.png'>";
        if(
$anticarro=='anticarro_plata')
                
$firma.="<img src='metopa/anticarro/plata.png'>";
        if(
$anticarro=='anticarro_bronce')
                
$firma.="<img src='metopa/anticarro/bronce.png'>";
        
        if(
$zapador=='zapador_oro')
                
$firma.="<img src='metopa/zapador/oro.png'>";
        if(
$zapador=='zapador_plata')
                
$firma.="<img src='metopa/zapador/plata.png'>";
        if(
$zapador=='zapador_bronce')
                
$firma.="<img src='metopa/zapador/bronce.png'>";
        
        if(
$carros=='carros_oro')
                
$firma.="<img src='metopa/carros/oro.png'>";
        if(
$carros=='carros_plata')
                
$firma.="<img src='metopa/carros/plata.png'>";
        if(
$carros=='carros_bronce')
                
$firma.="<img src='metopa/carros/bronce.png'>";
    
$firma.="</td>
  </tr>
  <tr>
    <td colspan='5' height='5'></td>
  </tr>
</table>"
;

echo 
"<div align='center' style='padding-top:100px;'>";

$mostrar=$firma;

echo 
$mostrar;
echo 
"</div>";

?>
En el momento que escribo header("Content-Type: image/jpeg"); me lanza el siguiente error:

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/thevode.com/web/eagle/genfirmas/formu.php:7) in /usr/home/thevode.com/web/eagle/genfirmas/formu.php on line 388

He probado mil scripts que he encontrado por ahí y no soy capaz de solucionarlo.

Un saludo y mil gracias.