You are here

function imagepicker_copy_uploaded_file in Image Picker 7

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_copy_uploaded_file()
  2. 5 imagepicker.module \imagepicker_copy_uploaded_file()
  3. 6.2 imagepicker.upload.inc \imagepicker_copy_uploaded_file()
2 calls to imagepicker_copy_uploaded_file()
imagepicker_upload_form_submit in ./imagepicker.upload.inc
Submit form
imagepicker_user_config_admin_form_submit in ./imagepicker.user.inc

File

./imagepicker.upload.inc, line 382

Code

function imagepicker_copy_uploaded_file($destination, $name) {
  if ($name && isset($_FILES['files']['tmp_name'][$name])) {
    $source = $_FILES['files']['tmp_name'][$name];
    $newsrc = imagepicker_file_unmanaged_copy($source, IMAGEPICKER_FILE_SCHEME . $destination);
    if ($newsrc) {
      $file = imagepicker_get_uploaded_file_name($destination, $name);
      $destination .= $file;
      $file_moved = imagepicker_file_unmanaged_move($newsrc, IMAGEPICKER_FILE_SCHEME . $destination);

      // might be renamed if a file of same name already exists
      $file_moved = drupal_substr($file_moved, strrpos($file_moved, DIRECTORY_SEPARATOR) + 1);
      return $file_moved;
    }
  }
  return FALSE;
}