You are here

function imagepicker_copy_uploaded_file in Image Picker 5

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

File

./imagepicker.module, line 348
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_copy_uploaded_file(&$destination, $name) {
  $source = $_FILES['files']['tmp_name'][$name];
  if (file_copy($source, $destination, FILE_EXISTS_RENAME)) {

    // Fix bug in drupal's file_copy function which uses '/' instead of
    // DIRECTORY_SEPARATOR for making directories. This causes problems on
    // Windows mashines.
    $source = str_replace('/', DIRECTORY_SEPARATOR, $source);
    $file = imagepicker_get_uploaded_file_name($destination, $name);
    $destination = $destination . $file;
    return @rename($source, $destination);
  }
  return FALSE;
}