Upload file button doesn´t work in Editor 2.1.1

Upload file button doesn´t work in Editor 2.1.1

jgcaudetjgcaudet Posts: 82Questions: 7Answers: 0
edited March 2023 in Editor

Hi.
I update Editor 1.7.3 to 2.1.1 and then my upload file button get an error :
Recoverable fatal error: Object of class Closure could not be converted to string in ... Upload.php on line 728
I did this and it worked in Editor 1.7.3 :

                    ->upload( 
                        Upload::inst( function ( $file, $id ) use ( $ParametrosSubida, $db ) {
                            return SubirFichero($file, $id, $ParametrosSubida, $db, 'contratos') ;
                        }) 
                        ->db( 'uploads_contratos', 'id', array(
                            'nombre' => Upload::DB_FILE_NAME,
                            'ext' => Upload::DB_EXTN,
                            'mimetype' => Upload::DB_CONTENT_TYPE,
                            'webpath' => '',
                            'systempath' => '',
                            'tiposubida' => ''))
                        ->dbClean( function ( $data ) use ( $ParametrosSubida ) {
                                return BorraHuerfanos($data, $ParametrosSubida);
                            })
                        ->validator(
                            Validate::fileExtensions(array( 'ods', 'csv', 'xls', 'xlsx', 'odt', 'doc', 'docx', 'pdf', 'png', 'jpg', 'gif' ), "Este tipo de archivo no se puede subir." ))
                    )
                    ->setFormatter( 'Format::nullEmpty' ),

Can you help me ?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin

    What does return SubirFichero($file, $id, $ParametrosSubida, $db, 'contratos') ; return? It should be a string id or number to uniquely identify the file, which can then be stored in the database.

    Allan

  • jgcaudetjgcaudet Posts: 82Questions: 7Answers: 0

    Theoretically an id.
    I mean theoretically because I change to this :
    _ Upload::inst( function ( $file, $id ) use ( $ParametrosSubida, $db ) {
    echo 'HOLA *' ;
    return SubirFichero($file, $id, $ParametrosSubida, $db, 'contratos') ; }) _
    and set variuos echo in "SubirFichero" and i don,t get these echo. So "SubirFichero" doesn´t execute

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin

    You might need to log it to a file. What I often do is:

    file_put_contents('/tmp/a', "Result : ...", FILE_APPEND);
    

    Then in your terminal you could do tail -f /tmp/a to watch information being written to it.

    Allan

  • jgcaudetjgcaudet Posts: 82Questions: 7Answers: 0

    Where do you want I write it ?
    I said that it seems that it doesn`t execute code inside function ( $file, $id ) {....}

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin

    In between line 2 and 3 in your code block above (i.e. before the return).

    If that function isn't being run, then I don't understand how you'd get an error such as Object of class Closure could not be converted to string in since that error should only happen after that function returns something other than a string.

    Allan

Sign In or Register to comment.