Problem displaying the web path of File upload

Problem displaying the web path of File upload

KeepMovingKeepMoving Posts: 28Questions: 7Answers: 0

Hi, I just purchased my license for editor and Im having an issue,

Im trying to display the web path of my uploaded file and I always get "No files" wich is the false condition of render function. also when I click on "Edit" it returns the file name stored in the database, also I can add files and save it into database but it does not display in table.
Here is column

{data:"archivo.web_path",
                        render: function(file_IdArchivo){
                           return  file_IdArchivo ?
                               '<a href="'+editor.file('archivo', file_IdArchivo).web_path+'" download>
<i class="fi-download"></i> Archivo</a> / '+  '<a href="'+editor.file('archivo', file_IdArchivo).web_path+'">
<i class="fi-eye"></i>Ver</a>' :
                               'No Files';
                            }
                    }

Im using left join for this because I have many relaltional fields.
Here is my PHP:

Field::inst( 'altaestudios.archivo' )
                ->setFormatter( 'Format::ifEmpty', null )
                ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/estudioNumero__ID__.__EXTN__' )
                    ->db( 'archivo', 'IdArchivo', array(
                        'NombreArchivo'    => Upload::DB_FILE_NAME,
                        'Tamano'    => Upload::DB_FILE_SIZE,
                        'web_path'    => Upload::DB_WEB_PATH,
                        'local_path' => Upload::DB_SYSTEM_PATH
                    ) 
                )

                    ->allowedExtensions( array( 'pdf'), "Archivo no válido" )
            )

->leftJoin( 'archivo', 'altaestudios.archivo', '=', 'archivo.IdArchivo')

TABLES:
Archivo
IdArchivo
NombreArchivo
Tamano
web_path
local_path

altaestudios
IdAltaEstudios
FechaEstudio
IdUsuario
archivo <- IdArchivo
IdLaboratorio
activo
TipoEstudio

Thanks for help :smile:

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Change:

    data:"archivo.web_path",

    to be:

    data: "altaestudios.archivo"
    

    You want it to point at the property that contains the file id. The file() method then looks that up to get the web_path (or any other property).

    Allan

  • KeepMovingKeepMoving Posts: 28Questions: 7Answers: 0

    Hi Allan,

    thank you for your help but now im getting 0 data in table just the message "Loading"
    and this in console
    Uncaught Unknown file id 0 in table archivo

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Can you show me your full DataTables initialisation as it stands now please?

    Allan

This discussion has been closed.