blueimp/jQuery-File-Upload — Issue #878: No PNG thumbnails created after rename
Author: Gojiras
Created: 2011-12-14 01:45:39+00:00
State: open

I'm having an issue with thumbnail creation with PNG files only. jpg and gif both still create thumbnails. Here are the changes that I've made to trim_file_name method:

```php
private function trim_file_name($name, $type) {
// Remove path information and dots around the filename, to prevent uploading
// into different directories or replacing hidden system files.
// Also remove control characters and spaces (\x00..\x20) around the filename:
$file_name = trim(basename(stripslashes($name)), ".\x00..\x20");
// Add missing file extension for known image types:
$file_name = preg_replace("/[^A-Za-z0-9 ._]/","",$file_name);
$file_name = strtolower(str_replace(array(' ','_'),array('-','-'),$file_name));
if (strpos($file_name, '.') === false &&
preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) {
$file_name .= '.'.$matches[1];
}
return $file_name;
}
```

I have it removing all special characters except period, underscore and space, then inserting a dash for any underscores or spaces. The file extension should still be intact since the period is left alone. I also find it weird that this only occurs with .png files.

Any Ideas?