Jump to content
Fórum Script Brasil
  • 0

Upload de Imagem


Anderson J Raimundo

Question

Olá. Estou com um problema.

Estou ajudando no desenvolvimento de site, onde podemos incluir notícias para serem exibidas posteriormente, além disso disponibilizamos para fazer upload de imagem para fazer parte da notícia a ser publicada.

Quando cadastramos a notícia sem a imagem não ocorre nenhum erro.

Porém se fizer upload da imagem ocorre o seguinte erro:

PHP Warning:  move_uploaded_file(IMGNOT/3_ADIANTAMENTO.PNG) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in E:\home\abrapneus\Web\Noticia\grvnot.php on line 67
PHP Warning:  move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move 'C:\WINDOWS\Temp\php61AC.tmp' to 'IMGNOT/3_ADIANTAMENTO.PNG' in E:\home\abrapneus\Web\Noticia\grvnot.php on line 67
<?php
If( $_REQUEST['cTp'] == 1 ){
    $cPasta = 'IMGNOT/'.$_SESSION['IDUSER'].'_'.StrToUpper($_FILES['IMG']['name']);
    If( $_FILES['IMG']['tmp_name'] != '' ){
        If( move_uploaded_file($_FILES['IMG']['tmp_name'], $cPasta ) ){
            $cAq = $_SESSION['IDUSER'].'_'.StrToUpper($_FILES['IMG']['name']);
        }Else{
            $cAq = '';
        }
    }Else{
        $cAq = '';
    }

        $cQuery = "INSERT INTO /*BASE*/NT002(NT002_TITULO,
                                             NT002_RESUMO,
                                             NT002_CONTEUDO,
                                             NT002_IMAGEM,
                                             NT002_LEGENDA,
                                             NT002_DATA,
                                             NT002_PUBLICACAO,
                                             NT002_DATA1,
                                             NT002_DATA2,
                                             NT002_DTINS,
                                             NT002_USERINS)
                 VALUES ('".fUrlEncode( $_POST['TITULO'] )."',
                         '".fUrlEncode( $_POST['RESUMO'] )."',
                         '".fUrlEncode( $_POST['CONTEUDO'] )."',
                         '".$cAq."',
                         '".fUrlEncode( $_POST['LEGENDA'] )."',
                         '".fInsDt($_POST['DATA'], 2)."',
                          ".fInsDt('DT_ATUAL', 3).",
                         '".fInsDt($_POST['DATA1'], 2)."',
                         '".fInsDt($_POST['DATA2'], 2)."',
                          ".fInsDt('DT_ATUAL', 3).",
                          ".$_SESSION['IDUSER']." )";
        
        If ( fExecQuery( $cQuery, $cConexao, 'I') ){    
            fCommit();
            $nNOT    = fIdIns();
            If( Count( $_POST['LOCAL'] ) > 0 ) $aLc = Array_keys($_POST['LOCAL']);
            
            For($x=0; $x < Count( $aLc ); $x++){
            
                $cQuery = "INSERT INTO /*BASE*/NT004(NT004_IDNOTICIA,
                                                     NT004_IDLOCAL,
                                                     NT004_USERINS)
                         VALUES ('".$nNOT."',
                                 '".$aLc[ $x ]."',
                                     ".$_SESSION['IDUSER']." )";
                
                If ( fExecQuery( $cQuery, $cConexao, 'I') ){    
                    fCommit();
                }Else{
                    $nUSER = 'Erro';
                }            
            } 
        }Else{
            $nUSER = 'Erro';
        }

    
}Else If( $_REQUEST['cTp'] == 2 ){
    
    If( $_FILES['IMG']['name'] ){
        $cPasta = 'IMGNOT/'.$_SESSION['IDUSER'].'_'.StrToUpper($_FILES['IMG']['name']);
        
        If( move_uploaded_file($_FILES['IMG']['tmp_name'], $cPasta ) ){
            $cImg = "NT002_IMAGEM   ='" . $_SESSION['IDUSER'] . "_" . StrToUpper($_FILES['IMG']['name'])."', ";
            if( File_Exists( 'IMGNOT/'.$_POST['IDIMG'] ) And $_SESSION['IDUSER'] . "_" . StrToUpper($_FILES['IMG']['name']) <>  $_POST['IDIMG'] ) 
                UnLink( 'IMGNOT/'.$_POST['IDIMG'] );
            
        }
        
    }

Desde já agradeço!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...