Directory Emphasis

1

I'm having directory localization problem when it involves a file or folder with accent. Here's the snippet below where I try to capture the size of the file:

$filepath = "$novocaminho".utf8_encode($arquivo);
$tamanho = filesize("$filepath");

In this case it is returning the following error: Warning: filesize (): stat failed for

In other case, where I check if it is a directory, when the directory is not accented, if returns true if it is a directory with accentuation it returns false .

if(is_dir(utf8_encode($novocaminho_implode)) == TRUE){

The past directories are of type string .

I've tried using utf8_encode ().

    
asked by anonymous 17.08.2017 / 19:48

2 answers

1

One suggestion is to convert all database into a html entity, as the php code follows:

>
$email = addslashes(htmlentities($_POST['email'], ENT_QUOTES,'UTF-8')); 

In this way, all special characters are converted, and at the time of displaying them, the browser itself will interpret it.

It will be converted according to the table available at link

á = á (& aacute)

ã = ã (& atilde)

and so on

    
17.08.2017 / 20:02
0

I noticed that the problem may be somewhere else in the code:

if(isset($novocaminho)){
    if(is_dir($novocaminho) == TRUE){

         $diretorio = dir(utf8_encode($novocaminho_implode));

         while (($arquivo = $diretorio->read()) !== false){

When my string, already changed with UTF-8 , is checked by if(is_dir()) , it returns false, but only returns false when the string comes with seated, otherwise it continues and runs through the directory normally.

Would it be the case to change my entire directory to run out of seats ?, but I have to show the user the seats. As I would if I am showing "printing" on the screen exactly the name of the files and folders that are in my directory.

Is there other ways to show the directory?

I pass the folder by a string $pastaraiz = "public/data/downloads"; . Because if I use $_SERVER['DOCUMENT_ROOT']; it will move to my current folder.

    
17.08.2017 / 21:45