Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function checkName($file)
- {
- $this->newName = null;
- $nospaces = str_replace(' ', '_', $file['name']);
- if ($nospaces != $file['name']) {
- $this->newName = $nospaces;
- }
- $nameparts = pathinfo($nospaces);
- $extension = isset($nameparts['extension']) ? $nameparts['extension'] : '';
- if (!$this->typeCheckingOn && !empty($this->suffix)) {
- if (in_array($extension, $this->notTrusted) || empty($extension)) {
- $this->newName = $nospaces . $this->suffix;
- }
- }
- if ($this->renameDuplicates) {
- $name = isset($this->newName) ? $this->newName : $file['name'];
- $existing = scandir($this->destination);
- if (in_array($name, $existing)) {
- $i = 1;
- do {
- $this->newName = $nameparts['filename'] . '_' . $i++;
- if (!empty($extension)) {
- $this->newName .= ".$extension";
- }
- if (in_array($extension, $this->notTrusted)) {
- $this->newName .= $this->suffix;
- }
- } while (in_array($this->newName, $existing));
- }
- }
- }
- protected function moveFile($file)
- {
- $filename = isset($this->newName) ? $this->newName : $file['name'];
- $success = move_uploaded_file($file['tmp_name'], $this->destination ."/".$class."/".$username." - ".$filename);
- if ($success) {
- $result = $file['name'] . ' was succesvol geupload';
- if (!is_null($this->newName)) {
- $result .= ', en is hernoemd naar ' . $this->newName;
- }
- $result .= '.';
- $this->messages[] = $result;
- } else {
- $this->messages[] = 'Kon het volgende bestand niet uploden: ' . $file['name'];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement