PHP upload external function
PHP upload external function
yusar
Posts: 3Questions: 0Answers: 0
hi Allan,
i tried to use an external function to handle upload for resizing and create a thumbnail, then store the file information in my class variable as an array,
so i patch file Upload.php in function db something like this
public function db ( $table, $pkey, $fields )
{
$this->_dbTable = $table;
$this->_dbPKey = $pkey;
if(is_callable($fields)) {
$this->_dbFields = $fields(); // this is my external upload handler call returning file info as an array
} else {
$this->_dbFields = $fields;
}
return $this;
}
so in editor model class initialization it look like this
->fields(
Field::inst( 'id' )
->upload( Upload::inst( function ($file, $id) { return $id; })
->db( 'files_table', 'id', function() {
$model_class->upload_and_resize(); // external function for resize and thumbnail
return $model_class->file_info; // file info after resizing
})
can you tell me is there a better way to do this?
forgive me for my bad english
regards
This discussion has been closed.
Replies
Its a clever idea that - it wasn't really the way I had thought of the
db()
method being used. I had intended that to be used only for database fields and a custom upload action would be used for the resizing action if required.Allan
yes, i already tried with custom upload action but then im having trouble inserting correct file name into database because the record already populated before resizing the image
btw, can i link my account with another account which already purchase Editor license? this happen because my company purchase Editor license with my company account
thanks Allan
That's correct - you would need to write the information into the database directly in the upload method if you go that way.
Regarding the Editor license - not a problem, could you drop me an e-mail (allan @ thisDomain.net) with the invoice number so I make sure I assign the correct license!
Regards,
Allan