multi file upload problem

multi file upload problem

stevencmonstevencmon Posts: 25Questions: 9Answers: 2

I've got the javascript side working but when my PHP code is invoked I get the following error:

An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'files.area_id' in 'on clause'

My PHP is:

Editor::inst( $db, 'areas' )
    ->fields(
        Field::inst( 'areas.id' )->set( false ),
        Field::inst( 'areas.site_id' )->setValue( $_SESSION['site_id'] ),
        Field::inst( 'areas.area_type' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'areas.area_name' ),
        Field::inst( 'areas.building_name' ),
        Field::inst( 'areas.floor' ),
        Field::inst( 'areas.room' )
    )
    ->join(
      Mjoin::inst( 'areas_images' )
        ->link( 'areas.id', 'areas_images.area_id' )
        ->link( 'files.id', 'areas_images.file_id' )
        ->fields(
          Field::inst( 'id' )
            ->setFormatter( 'Format::ifEmpty', null )
            ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/images/__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( function ( $file ) {
                        return $file['size'] >= 20000000 ?
                            "Files must be smaller than 20M" :
                            null;
              } )
              ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image" )
            )
         )
      )
      ->where( 'site_id', $_SESSION['site_id'] )
      ->where( 'id', $_POST['area_id'] )
      ->process( $_POST )
      ->json();

Thanks

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Could you add ->debug( true ) immediately before the ->process(...) call please? Then upload a file and show me the JSON response from the server. It will include information about the SQL Editor is generating and executing.

    Allan

  • stevencmonstevencmon Posts: 25Questions: 9Answers: 2

    {"fieldErrors":[],"error":"An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'files.area_id' in 'on clause'","data":[],"ipOpts":[],"cancelled":[],"debug":[{"query":"SELECTidas 'id',areas.idas 'areas.id',areas.site_idas 'areas.site_id',areas.area_typeas 'areas.area_type',areas.area_nameas 'areas.area_name',areas.building_nameas 'areas.building_name',areas.flooras 'areas.floor',areas.roomas 'areas.room' FROMareasWHEREsite_id= :where_0 ANDid= :where_1 ","bindings":[{"name":":where_0","value":"399","type":null},{"name":":where_1","value":"399","type":null}]},{"query":"SELECT DISTINCTareas.idas 'dteditor_pkey',areas_images.idas 'id' FROM areas as areas JOINfilesONareas.id=files.area_idJOINareas_imagesONareas_images.id=files.file_id","bindings":[]}]}

This discussion has been closed.