Ir para conteúdo
Fórum Script Brasil

Wilbert Joosen

Membros
  • Total de itens

    8
  • Registro em

  • Última visita

Sobre Wilbert Joosen

Wilbert Joosen's Achievements

0

Reputação

  1. Trabalhei com um for antes do switch... e não dava certo..sim entendi... Grato, Wilbert
  2. Então... gostaria de uma ajuda para melhorar esse que já tenho.. como disse já tentei mas sem sucesso. Grato
  3. Boa tarde galera... tenho hoje um script que faz upload de um unico arquivo, cria um tumb, coloca uma marca e transforma em png... porem agora gostaria de fazer com que ele fizesse uploads de varios arquivos de uma so vez... gostaria de uma ajuda, tentei com for, mas não consigo de jeito nenhum. Segue meu codigo: <?php $overlay = 'mascara.png'; $trans_r = 255; $trans_g = 255; $trans_b = 255; $cache_fs = 'cache/'; $cache_uri = 'http://localhost/upload_foto/cache/'; $srid = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['REMOTE_PORT'] . time()); $base_fs = $cache_fs . $srid; $base_uri = $cache_uri . $srid; if(!$overlay = imagecreatefrompng($overlay)) { $error = 'Erro ao abrir a máscara'; $show = 'error'; } else if(isset($_FILES[foto])) { switch($_FILES[foto][type]) { case 'image/jpeg': case 'image/pjpeg': $orig = imagecreatefromjpeg($_FILES[foto][tmp_name]); break; case 'image/png': $orig = imagecreatefrompng($_FILES[foto][tmp_name]); break; case 'image/gif': $orig = imagecreatefromgif($_FILES[foto][tmp_name]); break; default: $error = 'Formato de arquivo inválido'; $show = 'error'; } if($orig) { $orig_x = imagesx($orig); $orig_y = imagesy($orig); $overlay_x = imagesx($overlay); $overlay_y = imagesy($overlay); $image_x = 800;//Largura da imagem grande $thumb_x = 150;//Largura da imagem pequena $image_y = round(($orig_y * $image_x) / $orig_x); $thumb_y = round(($orig_y * $thumb_x) / $orig_x); //Posição da Máscara - Alinhado abaixo a esquerda $offset_x = 0; $offset_y = $image_y - $overlay_y; $image = imagecreatetruecolor($image_x, $image_y); imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y); imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b)); imagecopymerge($image, $overlay, $offset_x, $offset_y, 0, 0, $overlay_x, $overlay_y, 99); $thumb = imagecreatetruecolor($thumb_x, $thumb_y); imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $thumb_x, $thumb_y, $orig_x, $orig_y); imagepng($image, $base_fs . '-grande.png'); imagepng($thumb, $base_fs . '-pequena.png'); $image_uri = $base_uri . '-grande.png'; $thumb_uri = $base_uri . '-pequena.png'; } else { if(!$error) $error = 'Erro ao enviar a imagem'; $show = 'error'; } if(!isset($show)) $show = 'result'; } if($show == 'error') { echo "<h2>$error</h2>"; } else if($show == 'result') { echo "<h2>Imagem Redimensionada</h2>"; echo "<p><img src=\"$image_uri\"></p>"; echo "<h2>Imagem Pequena</h2>"; echo "<p><img src=\"$thumb_uri\"></p>"; } else { ?> <script> function addRow() { document.sendmessage.countx.value = parseInt(document.sendmessage.countx.value) + 1; var i = parseInt(document.sendmessage.countx.value); var table; if (document.all) table = document.all.uploadtable; else if (document.getElementById) table = document.getElementById('uploadtable'); if (table && table.rows && table.insertRow) { var tr = table.insertRow(table.rows.length); var td = tr.insertCell(tr.cells.length); data = '<input type="file" name="foto" class="textboxgray" style="Font-Family:Arial; Font-Size:11px; Color:#AA0000;"><br>'; td.innerHTML = data; } } </Script> <form name="sendmessage" enctype="multipart/form-data" method="post" action="index.php"> <B><Font Color="#AA0000">Mais arquivos?:</Font></B> <input type="button" name="add" value=" + " class="textboxgray" onClick="java script: addRow()" style="Font-Family:Arial; Font-Size:11px; Color:#000000;"> <Hr> <input type="hidden" name="countx" value="1"> <table border="0" cellspacing="1" cellpadding="2" id="uploadtable"> <tr> <td> <input type="file" name="foto" class="textboxgray" style="Font-Family:Arial; Font-Size:11px; Color:#AA0000;"> </td> </tr> </table> <input type="submit" name="Submit" value="Upload" class="textboxgray" style="Font-Family:Arial; Font-Size:11px; Color:#000000;"> </form> <?}?>
  4. Opa, bom dia a todos! Continuo a quebrar a cabeça... alguém tem alguma luz para mim???
  5. Segue o que estou fazendo: $materias1 = new notas(); $select_materias1 = $materias1->select()->where('cadastro_id='.$id_cadastro)->where('periodo_id='.$ano)->where('subperiodo_id='.'4'); $this->view->materiasp = $materias1->fetchAll($select_materias1); foreach($this->view->materiasp as $materias){ $materia = $materias->materia_id; $notas1 = new notas(); $select_notas1 = $notas1->select()->where('cadastro_id='.$id_cadastro)->where('periodo_id='.$ano)->where('subperiodo_id='.'4')->where('materia_id='.$materia); $this->view->notas1 = $notas1->fetchAll($select_notas1); } Mesmo assim continua mostrando só a primeira linha do bd...
  6. Serie assim: foreach($this->view->materiasp as $materias){ $materia = $materias->materia_id; $notas1 = new notas(); $select_notas1 = $notas1->select()->where('cadastro_id='.$id_cadastro)->where('periodo_id='.$ano)->where('subperiodo_id='.'4')->where('materia_id='.$materia); $this->view->notas1 = $notas1->fetchAll($select_notas1); } Detalhe: ele não está pegando só a ultima linha do BD, e sim só a primeira Obrigado pela atenção
  7. Boa tarde forenses... Bom tenho um código aqui... e preciso que ele repepita... foreach($this->view->materiasp as $materias){ $materia = $materias->materia_id; } $notas1 = new notas(); $select_notas1 = $notas1->select()->where('cadastro_id='.$id_cadastro)->where('periodo_id='.$ano)->where('subperiodo_id='.'4')->where('materia_id='.$materia); $this->view->notas1 = $notas1->fetchAll($select_notas1); Bom, preciso que pelo foreach a $materia receba os "materia_id" e passe para o $select_notas1, porem o foreach só pega a primeira linha... e teria de pegar todas. se alguém tiver uma luz... Grato
×
×
  • Criar Novo...