function chado_organism_add_image

2.x tripal_organism.chado_node.inc chado_organism_add_image($node)
3.x tripal_organism.chado_node.inc chado_organism_add_image($node)
1.x tripal_organism.module chado_organism_add_image($node)

Related topics

2 calls to chado_organism_add_image()
chado_organism_insert in tripal_organism/tripal_organism.module
When a new chado_organism node is created we also need to add information to our chado_organism table. This function is called on insert of a new node of type 'chado_organism' and inserts the necessary information.
chado_organism_update in tripal_organism/tripal_organism.module
Update organisms

File

tripal_organism/tripal_organism.module, line 418
tripal_organism Organism Module

Code

function chado_organism_add_image($node) {
  // check to see if a file was uploaded. If so then copy it to the images
  // directory for display with the organism
  if (isset($_FILES['files']) && $_FILES['files']['name']['organism_image'] && 
    is_uploaded_file($_FILES['files']['tmp_name']['organism_image'])) {
    $dest = file_directory_path() . "/tripal/tripal_organism/images";
    $validators = array(
      'file_validate_is_image' => array(),
    );
    file_check_directory($dest, FILE_CREATE_DIRECTORY, 'organism_image');
    if (!$file = file_save_upload('organism_image', $validators, $dest)) {
      drupal_set_message(t("Organism image was not uploaded."));
    }
    // move this image into the images directory
    file_move($file->filepath, $dest . "/" . $node->nid . ".jpg", FILE_EXISTS_REPLACE);
  }
}