Uploading a PDF file.

Uploading a PDF file.

mccloudmccloud Posts: 35Questions: 15Answers: 2
edited January 2018 in Editor

I have generated a table using the online generator and am now trying to adapt it so that I can upload a PDF file, but at the moment, it will only accept image uploads. Am I missing something.?

**PHP**
            ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
                ->db( 'files', 'id', array(
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    'web_path'    => Upload::DB_WEB_PATH,
                    'system_path' => Upload::DB_SYSTEM_PATH
                ) )
                ->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
                ->validator( Validate::fileExtensions( array( 'png', 'jpg', 'gif',pdf' ), "Please upload" ) )
            )
        
    )
    ->process( $_POST )
    ->json();


**JS**
              {
                data: "file",
                render: function ( file_id ) {
                    return file_id ?
                        '<img src="'+editor.file( 'files', file_id ).web_path+'"/>' :
                        null;
                },
                defaultContent: "No image",
                title: "Image"
            }

Replies

  • tangerinetangerine Posts: 3,349Questions: 37Answers: 394
    array( 'png', 'jpg', 'gif',pdf' )
    

    Missing single quote.

  • mccloudmccloud Posts: 35Questions: 15Answers: 2

    No, that didn't help.

  • allanallan Posts: 61,715Questions: 1Answers: 10,106 Site admin

    What happens when you upload a pdf file? What error message do you get - if any?

    Allan

  • mccloudmccloud Posts: 35Questions: 15Answers: 2
    edited January 2018

    I managed to solve the problem by refreshing the page again. It was a typo area in the code, as mentioned by tangerine. Thanks for the assistance.

This discussion has been closed.