Creating two links with path of a Explode

Asked

Viewed 33 times

0

I am developing a project and next to the form, the user can upload a file. In this case, the registration part next to the upload(s) I already managed to do, now I am creating the display/change of the record. And that’s what I’m stalling on.

In case, I recorded the upload path and played on the bank bringing this path to the display/change screen with exploded to split the files...but even with exploded, he still understands as a link only. As follows:.

<? 

#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 case what could be done so that each part of the file is treated with a different link? And taking advantage while changing(field below) the old file will probably have to be deleted from the server...there is some other way besides Ulink?

2 answers

0

I believe the mistake is in foreach you’re not doing it right 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>';
    }
} 
?>

0

That part worked. Now the second question concerning the exclusion of the Link is missing. I am doing so 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 Registered File2.php 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 delete only one part of the record and in relation to using Ulink()...but in this method even the variable is not arriving in the other page...it arrives empty, only the code is appearing.

I await this other party.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.