Skip to content

Instantly share code, notes, and snippets.

@mariuswilms
Created November 29, 2009 13:55
Show Gist options
  • Select an option

  • Save mariuswilms/244918 to your computer and use it in GitHub Desktop.

Select an option

Save mariuswilms/244918 to your computer and use it in GitHub Desktop.
<?php
function transferTo($via, $from) {
extract($from);
$path = Media::short($file, $mimeType) . DS;
if (is_file($file)) {
$checksum = hash_file('adler32', $file);
} elseif (is_file($via['file'])) {
$checksum = hash_file('adler32', $via['file']);
} else {
return false;
}
$path .= $checksum;
if (!empty($mimeType)) {
$extension = MimeType::guessExtension($mimeType);
}
if (!empty($extension)) {
$path .= '.' . strtolower($extension);
}
return $path;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment