Creating two links with an Explode path

0

I'm developing a project and next to the form, the user can upload a file. In the case, the registration part next to the upload (s) I have already been able to do, now I am creating the view / change of the record. And that's what I'm packing.

In case, I registered the upload path and threw it in the bank bringing this path to the display / change screen with explode to split the files ... but even with explode, it still understands as a link only. As shown below.

<? 

#definir o char-set da página 
setlocale(LC_ALL,"pt_BR"); 
header('Content-type: text/html; charset=windows-1252');    

set_time_limit(120); //Tempo limite de execução 
ERROR_REPORTING (E_ERROR); //Exibe somente erros fatais 

 #Variáveis de Data e Hora  
$dataAt = date('d/m/Y');    
$horaAt = date('H:i:s');

$inserir = 0;   

$usuario = strtolower($_SERVER["LOGON_USER"]);
$usuario_1 = split('\\', $usuario);
$usuario = $usuario_1[1];



//variaveis para execução do SQL 
SQL(); 
global $sql; 

$idd = $_REQUEST["id"];//Varíavel para buscar o campo id do registro 

//echo "O ID para alteração é o: ".$idd; 
//echo "<BR><BR>"; 

#Cria a consulta inicial 
$altEve = "SELECT [id],[mudanca],[tarefa]
  ,[descricao],[ambiente],[empresa],[reg_afet]
  ,[sist_afet],[hw_afet],[host_name],[serv_afet]
  ,[conclusao],[obs],[data_exec],[obs2],[upload]
    FROM [Passagem].[dbo].[tb_eventos_relev_tst] WHERE ID= $idd"; 

//echo $altPas;
//echo "<BR>";

#realiza a busca pelos dados do registro 
$result = $sql->execute($altEve); 
    if($tbl = $result) 
        { 
            $codigo = $tbl["id"];
            $codigo = $tbl["mudanca"];
            $codigo = $tbl["tarefa"];
            $codigo = $tbl["descricao"];
            $codigo = $tbl["ambiente"];
            $codigo = $tbl["empresa"];
            $codigo = $tbl["reg_afet"];
            $codigo = $tbl["sist_afet"];
            $codigo = $tbl["hw_afet"];
            $codigo = $tbl["host_name"];
            $codigo = $tbl["serv_afet"];
            $codigo = $tbl["conclusao"];
            $codigo = $tbl["obs"];
            $codigo = $tbl["obs2"];
            $codigo = $tbl["data_exec"];
            $codigo = $tbl["upload"];
            } 
    else 
        { echo "Registro não localizado"; } 

    #Inicia o tratamento dos registros      
    while (!$result -> EOF) { 
        $id = $result->Fields['id']->Value; 
        $mudanca = $result->Fields['mudanca']->Value;   
        $tarefa = $result->Fields['tarefa']->Value;     
        $descricao = $result->Fields['descricao']->Value;   
        $ambiente = $result->Fields['ambiente']->Value;     
        $empresa = $result->Fields['empresa']->Value;   
        $reg_afet = $result->Fields['reg_afet']->Value;     
        $sist_afet = $result->Fields['sist_afet']->Value;   
        $hw_afet = $result->Fields['hw_afet']->Value;   
        $host_name = $result->Fields['host_name']->Value;   
        $serv_afet = $result->Fields['serv_afet']->Value;   
        $conclusao = $result->Fields['conclusao']->Value;   
        $obs = $result->Fields['obs']->Value;   
        $data_exec = $result->Fields['data_exec']->Value;   
        $obs2 = $result->Fields['obs2']->Value;     
        $upload = $result->Fields['upload']->Value;     


        $dataEx = substr($data_exec, 8,2)."/".substr($data_exec,5,2)."/".substr($data_exec, 0,4);

        //echo $upload;
        //echo "<BR>";
        $uploadExi = explode(' , ',$upload); 
         //foreach($uploadExi as $valores) 
            //{ 
                //echo $valores.'<BR>'; 
            //}


        #Move para o registro seguinte
        $result->MoveNext();

    } 

And in the Html below

 ...
 <p>
                <label>Anexo:</label>
                <input type="hidden" name="eveArquivoAntigo" id="idArquivoAntigo" value="<? echo $upload; ?>" /> 
                <? 
                    if($upload == '' || $upload == 'Sem arquivo anexo') { 
                        echo 'Não existem arquivos anexos para este registro'; 
                    } else { 
                 ?> 
                    <a href="../UTILS/<?foreach($uploadExi as $valores) { echo $valores; } ?>" target="_blank">
                    <?foreach($uploadExi as $valores)   { echo $valores.'<BR>'; }?></a><br> 
                <?  
                    } 
                ?>
            </p>
            <p> 
                <label for="idArquivo">Alterar anexo:</label>
                <input type="file" name="eveArquivo[]" id="idArquivo" disabled />
            </p><br>

In the case what could be done so that each part of the file is handled with a different link? And taking advantage of the change (field below) the old file will probably have to be deleted from the server ... is there any way other than Ulink?

    
asked by anonymous 20.09.2017 / 04:29

2 answers

0

I believe the error is in foreach are not you doing it correctly with the hyperlink ?

<?php
if($upload == '' || $upload == 'Sem arquivo anexo') { 
    echo 'Não existem arquivos anexos para este registro'; 
} else { 
    foreach($uploadExi as $valores)   { 
        echo '<a href="../UTILS/' . $valores . '" target="_blank">'.$valores.'</a><BR>';
    }
} 
?>
    
20.09.2017 / 09:59
0

That part worked out. The second link exclusion question is now missing. I'm doing this in the case

if($upload == '' || $upload == 'Sem arquivo anexo') { 
                        echo 'Não existem arquivos anexos para este registro'; 
                    } else { 
                        foreach($uploadExi as $valores)   { 
                            echo '<a href="../UTILS/' . $valores . '" target="_blank" >'.$valores.'</a>&nbsp;&nbsp;
                            <input type="text" name="hidValor" value="'.$valores.'"/>
                            <input type="submit" name="ExcluirAnexo" value="Excluir Anexo" class="botaoExc"><BR>
                            '; //disabled
                    } }

The Regista2.php file is this

//Inicia o Case/Switich de opções 
switch(get_post_action('Incluir','Alterar','Excluir','ExcluirAnexo')) {

    //Incluir registro 
    case 'Incluir':
        //está parte do código está OK 

        break;
    //Alterar registro
    case 'Alterar': 
        //está parte do código está OK

        break;  

        //Exclusão
        case 'Excluir': 
        //está parte do código está OK

        break; 

        //Exclusão de Anexo 
        case 'ExcluirAnexo':    


            $idPag = $_REQUEST['eveId'];//Id da página
            $id = $_REQUEST['hidId']; //Busca campo ID na página 

            echo $id."<BR>";

            $excAnexo = $_REQUEST["hidValor"];
            echo $encAnexo."<BR>";

            //Efetua a consulta no banco 
            $consulta = "SELECT [upload] FROM [dbo].[tb_eventos_relev_tst] REPLACE ('$encAnexo','$encAnexo','') WHERE [id]=$id";
            echo $consulta."<BR>";  
            //Executa a consulta
            //$result = $sql->execute($consulta); 

            //Exibe o resultado 
            echo "O arquivo $encAnexo foi excluído com sucesso<BR>"; 
            echo "<br><p><a href='../FILES/alterar_even_tst.php?id=$idPag'>Clique aqui para voltar a tela de alteração</a></p>";


        break;

        default: 
            //NAda

}   

In case the doubt would be the same in relation to exclude only part of the record and in relation to using Ulink () ... however in this method neither the variable is arriving on the other page ... it arrives empty, only the code is showing up.

Looking forward to this other part.

    
22.09.2017 / 04:57