Lançado Adianti Framework 7.6!
Clique aqui para saber mais
problema com download de arquivo, localhost funciona, nao funcio Estou tendo um proble,ma com um comportamento diferente entre localhost e no servidor, Fiz uma rotina de download e no servidor não faz o download e não envio nenhum destes parametros abaixo servidor: http://www.suafotoaqui.com.br/suafoto4/index.php?class=PedidoUserList&wm-ueug=%22c34a7666-4bf6-7ae8-81a8-9ff34cb5c2c9%22&wm-fgug=1&__cfduid=d0fbdd93429d043638e5fb43179162d021466861639&PHPSESS...
LJ
problema com download de arquivo, localhost funciona, nao funcio  
Estou tendo um proble,ma com um comportamento diferente entre localhost e no servidor,
Fiz uma rotina de download e no servidor não faz o download e não envio nenhum destes parametros abaixo

servidor:
www.suafotoaqui.com.br/suafoto4/index.php?class=PedidoUserList&w

  1. <?php
  2. /**
  3.  * SaleForm Registration
  4.  * @author  <your name here>
  5.  */
  6. class PedidoUserForm extends TPage
  7. {
  8.     protected  $form// form
  9.     protected  $datagrid;
  10.     protected  $pageNavigation;
  11.     protected  $formFields;
  12.     protected  $loaded;
  13.     
  14.     /**
  15.      * Class constructor
  16.      * Creates the page and the registration form
  17.      */
  18.     function __construct()
  19.     {
  20.         parent::__construct();
  21.        
  22.         // creates the form
  23.         $this->form   = new TForm('form_Pedido');
  24.         $panel_master = new TPanelGroup'Pedido' );
  25.         $vbox = new TVBox;
  26.         $vbox->style 'width: 100%';
  27.         $this->form->add($panel_master);
  28.         $panel_master->add($vbox);
  29.         
  30.         $frame_general = new TFrame;
  31.         $frame_general->class 'tframe tframe-custom';
  32.         $frame_general->setLegend('Pedido');
  33.         $frame_general->style 'background:whiteSmoke';
  34.         $table_general = new TTable;
  35.         $table_general->width '100%';
  36.         $frame_general->add($table_general);
  37.       
  38.         
  39.         $vbox->add$frame_general );
  40.          
  41.         // master fields
  42.         $id             = new TEntry('id');
  43.         $datap          = new TDate('datap');
  44.         // o nome do status  e total pega de uma funcao no model pedido
  45.         $status_id      = new TEntry('status_nome');
  46.         $total          = new TEntry('TransfValor');
  47.    
  48.         
  49.         $id->setSize(40);
  50.         $datap->setSize(100);
  51.         $total->setSize(80);
  52.         $id->setEditable(false);
  53.         $datap->setEditable(false);
  54.         $status_id->setEditable(false);
  55.         $total->setEditable(false);
  56.         // general fields
  57.         $table_general->addRowSet( new TLabel('ID'),  $id );
  58.         $table_general->addRowSet$label_date     = new TLabel('Data '), $datap );
  59.         $table_general->addRowSet( new TLabel('Status'), $status_id );
  60.         $table_general->addRowSet( new TLabel('Total'), $total );
  61.         
  62.         //criar a datagrid dos itens 
  63.         $this->datagrid = new TQuickGrid;
  64.         //<img src=\"thumbnail.php?thumb=$file\" alt=\"thumb\" />
  65.         $this->datagrid->enablePopover('Imagem'"<img src='{imagem}' height='100' >");
  66.         $this->datagrid->addQuickColumn('ID''produto_id''center''10%');
  67.         $this->datagrid->addQuickColumn('Status''produto_status_id''center''10%');
  68.         $this->datagrid->addQuickColumn('Produto''produto_nome''left''30%');
  69.         $this->datagrid->addQuickColumn('Tam''preco_tam''left''10%');
  70.         $this->datagrid->addQuickColumn('Qtd''qtd''left''10%');        
  71.         $pr $this->datagrid->addQuickColumn('Preco','preco_val''right''10%');
  72.         $st $this->datagrid->addQuickColumn('Subtotal','={qtd} * {preco_val}''right','10%');
  73.     
  74.         // creates two datagrid actions
  75.         $action1 = new TDataGridAction(array($this'onDownload'));
  76.         $action1->setLabel('Tamanho Comprado');
  77.         $action1->setImage('fa:download');
  78.         $action1->setField('produto_id');
  79.         $action1->setDisplayCondition( array($this'displayDownload') );
  80.         // creates two datagrid actions
  81.         $action2 = new TDataGridAction(array($this'onDownload1200'));
  82.         $action2->setLabel('Tamanho 800x1200');
  83.         $action2->setImage('fa:download green');
  84.         $action2->setField('produto_id');
  85.         $action2->setDisplayCondition( array($this'displayDownload1200') );
  86.         $this->datagrid->addAction($action1);
  87.         $this->datagrid->addAction($action2);
  88.         
  89.         $this->datagrid->createModel();    
  90.         
  91.         $format_value = function($value) {
  92.             if (is_numeric($value)) {
  93.                 return 'R$ '.number_format($value2',''.');
  94.             }
  95.             return $value;
  96.         };
  97.         
  98.         $pr->setTransformer$format_value );
  99.         $st->setTransformer$format_value );        
  100.         
  101.         $this->formFields = array($id,$datap$status_id$total);
  102.         $this->form->setFields$this->formFields );
  103.         
  104.         // create the page container
  105.         $container = new TVBox;
  106.         $container->add($this->form);
  107.         $container->add($this->datagrid);
  108.         parent::add($container);
  109.     }
  110.     
  111.      /**
  112.      * Define when the action can be displayed
  113.      */
  114.     public function displayDownload$object )
  115.     {
  116.         if($object->produto_status_id=='4')
  117.             {return TRUE;}
  118.         return FALSE;
  119.     }   
  120.      /**
  121.      * Define when the action can be displayed
  122.      */
  123.     public function displayDownload1200$object )
  124.     {
  125.         if($object->produto_status_id<>'1')
  126.             {return TRUE;}
  127.         return FALSE;
  128.     }    
  129.     /**
  130.      * method onEdit()
  131.      * Executed whenever the user clicks at the edit button da datagrid
  132.      */
  133.     function onEdit($param)
  134.     {
  135.         try
  136.         {
  137.             TTransaction::open('ecommerce');
  138.             if (isset($param['key']))
  139.             {
  140.                 $key $param['key'];
  141.                 
  142.                 
  143.                 $object = new Pedido($key);
  144.                 $object->datap TDate::date2br($object->datap);
  145.                 $sale_items $object->getPedidoItems();
  146.                 
  147.                 TSession::setValue('pedido_id',$object->id);
  148.                 foreach( $sale_items as $item )
  149.                 {
  150.                     $obj2 = new StdClass;
  151.                     $obj2->produto_id $item->produto_id;
  152.                     $obj2->produto_status_id $item->produto_status_id;
  153.                     $obj2->produto_nome $item->produto->nome;
  154.                     $obj2->preco_tam $item->preco_tam;                    
  155.                     $obj2->qtd $item->qtd;
  156.                     $obj2->preco_val $item->preco_val;
  157.                     $obj2->imagem $item->produto->imagem;
  158.                     
  159.                     $this->datagrid->addItem($obj2);
  160.                 }
  161.                 $this->form->setData($object); // fill the form 
  162.                 TTransaction::close(); // close transaction
  163.             }
  164.         }
  165.         catch (Exception $e// in case of exception
  166.         {
  167.             new TMessage('error''<b>Error1</b> ' $e->getMessage());
  168.             TTransaction::rollback();
  169.         }
  170.     }
  171.     function onDownload($param)
  172.     {
  173.         try
  174.         {
  175.             if (isset($param['produto_id']))
  176.             {
  177.                 $produto_id $param['produto_id'];  // get the parameter $key
  178.                 $pedido_id TSession::getValue('pedido_id');
  179.                 TTransaction::open('ecommerce'); // open a transaction
  180.                 $items = array();
  181.                 $pedido = new Pedido($pedido_id); // instantiates the Active Record
  182.                 $items $pedido->getPedidoItems();
  183.                 
  184.                 foreach ($items as $item)
  185.                 {
  186.                     if ($item->produto_id == $produto_id)
  187.                     { 
  188.                        $item->down ++;
  189.                        $pedido->store();
  190.                        TPage::openFile($item->photo_path);
  191.                     }
  192.                 }
  193.                
  194.                 TTransaction::close(); // close the transaction
  195.                 TApplication::gotoPage('PedidoUserList'); 
  196.                 
  197.             }
  198.         }
  199.         catch (Exception $e// in case of exception
  200.         {
  201.             new TMessage('error'$e->getMessage()); // shows the exception error message
  202.             TTransaction::rollback(); // undo all pending operations
  203.         }
  204.     
  205.     }
  206.     function onDownload1200($param)
  207.     {
  208.         try
  209.         {
  210.             if (isset($param['produto_id']))
  211.             {
  212.                 $produto_id $param['produto_id'];  // get the parameter $key
  213.                 TTransaction::open('ecommerce'); // open a transaction
  214.                 $object = new Produto($produto_id); // instantiates the Active Record
  215.                 $pedido_id TSession::getValue('pedido_id');
  216.                 $pedido = new Pedido($pedido_id);
  217.                 $items $pedido->getPedidoItems();
  218.                 foreach ($items as $item)
  219.                 {
  220.                     if ($item->produto_id == $produto_id)
  221.                     { 
  222.                        $item->down1200 ++;
  223.                        $pedido->store();
  224.                     }
  225.                 }                
  226.                 TPage::openFile($object->photo_path);
  227.                 TTransaction::close(); // close the transaction
  228.                 TApplication::gotoPage('PedidoUserList'); 
  229.             }
  230.         }
  231.         catch (Exception $e// in case of exception
  232.         {
  233.             new TMessage('error'$e->getMessage()); // shows the exception error message
  234.             TTransaction::rollback(); // undo all pending operations
  235.         }
  236.     }    
  237.     
  238.     /**
  239.      * method onEdit()
  240.      * Executed whenever the user clicks at the edit button da datagrid
  241.      */
  242.     function onReload($param)
  243.     {
  244.         try
  245.         {
  246.             TTransaction::open('ecommerce');
  247.             
  248.             if (isset($param['key']))
  249.             {
  250.                 $key $param['key'];
  251.                 
  252.                 $object = new Pedido($key);
  253.                 $object->datap TDate::date2br($object->datap);
  254.                 $sale_items $object->getPedidoItems();
  255.                 
  256.                 TSession::setValue('pedido_id',$object->id);
  257.                 
  258.                 foreach( $sale_items as $item )
  259.                 {
  260.                     $obj2 = new StdClass;
  261.                     $obj2->produto_id $item->produto_id;
  262.                     $obj2->produto_status_id $item->produto_status_id;
  263.                     $obj2->produto_nome $item->produto->nome;
  264.                     $obj2->preco_tam $item->preco_tam;                    
  265.                     $obj2->qtd $item->qtd;
  266.                     $obj2->preco_val $item->preco_val;
  267.                     $obj2->photo_path $item->photo_path;
  268.                     
  269.                     $this->datagrid->addItem($obj2);
  270.                 }
  271.                 $this->form->setData($object); // fill the form 
  272.                 TTransaction::close(); // close transaction
  273.             }
  274.         }
  275.         catch (Exception $e// in case of exception
  276.         {
  277.             new TMessage('error''<b>Error1</b> ' $e->getMessage());
  278.             TTransaction::rollback();
  279.         }
  280.     }    
  281.     /**
  282.      * shows the page
  283.      */
  284.     function show()
  285.     {
  286.         $this->onReload($param);
  287.         parent::show();
  288.     }    
  289. }
  290. ?>



Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (1)


NR

O servidor está configurado para exibir os erros? Analise o retorno da requisição após clicar no link para download.