Permission problem uploading files

2

I've created a product listing that contains a upload function for images. The operation is being done normally, the file goes to the given folder, and through the system until I can see the image from which I did the upload .

The problem is the time to change, because when I do the upload system, the file goes with access restrictions.

  

PS: Only when I do upload on the system, because when I copy the file normally through windows everything is correct and does not give a problem at all.

Below is the upload method:

public static function uploadFile($file, $nomeDocumento, $diretorio, $extValidas = array()) {
    $ext = pathinfo ( $file['name'], PATHINFO_EXTENSION );

    try {

        if (!isset ( $file['error'] ) || is_array( $file['error'] )) {
            throw new RuntimeException( 'Parâmetros Inválidos.' );
        }

        switch ($file['error']){
            case UPLOAD_ERR_OK :
                break;
            case UPLOAD_ERR_NO_FILE :
                throw new RuntimeException( 'Nenhum arquivo Enviado.' );

            /*
             * case UPLOAD_ERR_INI_SIZE:
             * case UPLOAD_ERR_FORM_SIZE:
             * throw new RuntimeException('Limite de tamanho de arquivo excedido.');
             */

            default :
                throw new RuntimeException( 'Erro Desconhecido' );
        }

        // if ($file['size'] > 1000000) { throw new RuntimeException('Limite de tamanho de arquivo excedido.'); }

        if (!in_array( $ext, $extValidas )){
            throw new RuntimeException( "Formato de arquivo inválido\nArquivos permitidos: " . implode( ', ', array( 'pdf', 'PDF', 'jpg', 'JPG', 'png', 'PNG', 'jpeg', 'JPEG')));
        }

        if (!move_uploaded_file( $file['tmp_name'], $diretorio . DIRECTORY_SEPARATOR . $nomeDocumento.'.'.$ext)) {
            throw new RuntimeException ( 'Failed to move uploaded file.' );
        }

        return true;
    } catch ( RuntimeException $e ) {
        return $e->getMessage ();
    }
}
  

Q: I am using YiiFramework, and saving the files inside: protected / data / products / .

    
asked by anonymous 03.07.2017 / 18:47

0 answers