Image upload but file id won't add in another table as foreign key
Image upload but file id won't add in another table as foreign key
bassam2008
Posts: 2Questions: 1Answers: 0
Editor::inst( $db, 'tb_news' , 'news_id')
->fields
(
Field::inst( 'news_id' ),
Field::inst( 'news_title' ),
Field::inst( 'news_text' ),
Field::inst( 'news_date' ),
Field::inst( 'image' )
->setFormatter( 'Format::ifEmpty', null )
->upload
( Upload::inst( $_SERVER['DOCUMENT_ROOT'] . '/datatable-demo-server-side-in-phpmysql-and-ajax' . '/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
(
function ( $file )
{
return$file['size'] >= 5242880 ?
"Files must be smaller than 5M" :
null;
}
)
->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )
)
)
->process( $_POST )
->json();
this what I used to upload and insert
sorry for my bad English
This discussion has been closed.
Answers
Hi,
Format::ifEmpty
requires the Editor 1.5.4 package which was released yesterday. Are you using the 1.5.4 version of the PHP libraries for Editor?Allan