getimagesize() does not work on Plesk + Windows

Asked

Viewed 162 times

0

I have the following code:

$info = getimagesize($this->tmp_name);

When analyzing the variable $info, I found that it was blank.

  • I checked that the GD library was installed.
  • I checked the write permissions in the folders.
  • I checked the variable $this->tmp_name, its value was C: Windows Temp php85CD.tmp
  • I checked that the directive open_basedir was different: *D: Inetpub vhosts meusite.com httpdocs* (shouldn’t be C: Windows Temp\?)

If not, what might be the problem since the upload doesn’t work?

1 answer

2

Let’s go in pieces:

  1. getimagesize() expects the first argument to be an image file. Reporting the temporary file may be the cause of the problem;

    1.1. And this does not mean that the function is the one preventing the upload. To check if there was an error in the upload you should check the index value error in $_FILES:

    if( $_FILES['upload']['error'] == UPLOAD_ERR_OK ) {
    
        // Sucesso! Trabalhe com move_uploaded_file()
    
    } else {
    
        // Uh-oh :(
    }
    
  2. $info being "white" probably means you echoed a FALSE, value returned by getimagesize() when this fails.

    2.1. If you failed and returned FALSE and you did not see any errors, your alerts are disabled or too low to display Warning:

    error_rerpoting( E_ALL );
    ini_set( 'display_errors', TRUE );
    
  3. open_basedir is different from upload_tmp_dir.

    The value received is correct because it restricts file manipulation functions to operate on files outside the directory root.

  • I checked the environment and it is Windows Server/IIS. It will be some limitation/configuration because it is not Apache?

Browser other questions tagged

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