Hey,
It's not common on web files to use spaces within the files/folders names, however it might happen. Currently the FileField Sources doesn't support files that have spaces within their full path, because the full path is retrieved url encoded from the db. If you try to upload a file with spaces, you will get this:
- Warning: filesize(): stat failed for /full_path_image/IMG_3817%201.jpg in filefield_sources_save_file() (line 341 of /full_path/sites/all/modules/contrib/filefield_sources/filefield_sources.module).
- The specified file /full_path/sites/default/files/general_media/images/goverment/IMG_3817%201.jpg could not be copied, because no file by that name exists. Please check that you supplied the correct filename.
- File upload error. Could not move uploaded file.The selected file could not be used because the file does not exist in the database.
I created a simple patch that fix this issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | filefield_sources--broken_filename_paths--1368680-D7.patch | 753 bytes | captainpants |
Comments
Comment #1
Bartox commentedComment #2
quicksketchThe file path shouldn't be URL encoded in the database. My guess here is that we're not properly urldecoding something on the way in. Which source are you experiencing this problem with? We should call urldecode() *before* the call to filefield_sources_save_file().
(This may have already been fixed as part of #967992: remote.inc: Get filename from Content-Type or Content-Disposition, but is not yet in an official release.)
Comment #3
quicksketchI couldn't confirm this problem with normal file uploads, referencing existing files via autocomplete, nor through the file attach approach. I need more information on how to reproduce the problem.
In the database, files are stored unencoded:
This may have been fixed already as part of #967992: remote.inc: Get filename from Content-Type or Content-Disposition, which increased our file name robustness for the remote URL source.
Comment #4
hjvedvik commentedI get this error when selecting an existing file through elFinder 0.7 if the file has spaces or contains non ASCII characters. I'm using FileField Sources 1.6. Spaces in directories works fine. The quickest fix I found was to url decode the file path in the filefield_sources_save_file function. But I dont know if this is the best way?
Comment #5
dieuweI get this error when trying to upload a file with spaces:
(using FileField Sources 1.8 with elFinder 0.8)
Comment #6
Maglor commentedI get this error as well, when using the elfinder File browser option, added by the elFinder File Field Source module added to it. Any progress on this?
Comment #7
captainpants commentedSwitched to major as this is a pretty big piece of functionality that is being broken.
This problem is occurring for me as well. Below is a patch applicable to the 7.x-1.9 release.
Comment #8
Leeteq commentedIsnt this something that would be solved in combination with https://www.drupal.org/project/transliteration ?
Comment #9
roman_l commentedSame problem here, with special chars like french accents (é, è etc...).
Patch provided in #7 by captainpants seems to do the trick, thanks !
Transliteration seems to be used in filefield_sources module, for file names but not for path ?
Comment #10
quicksketchMoving this to elFinder. Because Drupal core does not urlencode() paths when saving files, neither should elFinder. It seems as though when it's uploading files it may be encoding the names first, which it should not be doing.
Comment #11
ph0enix commentedComment #12
ph0enix commentedMoved #34