1) CCK 5.x-1.10
2) ImageField 5.x-2.2
3) 755 permission, www-data owner for files/ directory; 777, root for tmp/ directory
4) private download method
5) configuration (all that matters):
Permitted upload file extensions: jpg jpeg png gif
6) I expect to be able to upload all 4 types of files (jpg jpeg png gif)
7) I can only upload the first file type (jpg). A javascript alert box appears when trying to upload jpeg, png or gif files.
8) Create new content type
Create imagefield cck field with the 4 file types above
Create new node, try to upload picture with extension jpeg, png, gif
An alert box is displayed saying you can't upload the image.
I have investigated this problem and found that it is caused by a non-global javascript replace function. The function call on line 14 of imagefield.js
accept = this.accept.replace(',','|');
only replaces the first comma (the one separating jpg and jpeg). Taking the configuration above, the value of accept would be set to 'jpg|jpeg,png,gif'. It should be 'jpg|jpeg|png|gif'. The correct replace function is
accept = this.accept.replace(/\,/g,'|');
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | imagefield-regex.patch | 634 bytes | v1nce |
| #4 | Picture 2.png | 25.69 KB | asugene |
| #1 | imagefield-352939-1.patch | 473 bytes | pathfinderelite |
Comments
Comment #1
pathfinderelite commentedHere is a patch.
Comment #2
drewish commentedit actually needs to consume whitespace between the extensions as well. i think the 6.x code does this.
Comment #3
nath commentedSeems to work for me though.
Comment #4
asugene commentedYes I get the same problem. I have attached the same error message. I do not have this problem in the 5.x-2.1 version. Only in the upgrade version of 5.x-2.2. Tested it on two sites on two different servers and two different browsers.
Comment #5
drewish commentedtry the -dev version out. it's got some code to fix this already.
Comment #6
drewish commentedactually, if you're using filefield, update that too: http://drupal.org/node/355195
Comment #7
drewish commentedmarked #328205: Accepted filetypes not allowed to be uploaded by Firefox as a duplicate since this has a patch.
Comment #8
arsart commentedHi all,
Doesn't work for me on -dev version :(
Comment #9
lelizondo commentedIt's not working for me either.
Comment #10
jbc commentedExperiencing same issue. Will test with dev version asap.
Comment #11
Boletus commentedtried to upgrade to the the 5.2-dev version to get rid of the file type bug. Got a:
Fatal error: Call to undefined function _content_admin_display_contexts() in /home/mydomain.com/public_html/shop2/sites/all/modules/imagefield/imagefield.install on line 81.
Drupal halted the install.
Uploaded the 5.2.2 version again and run update.php. Got a two errors:
array_merge() [function.array-merge]: Argument #2 is not an array in /home/mydomain.com/public_html/shop2/update.php on line 309.
Invalid argument supplied for foreach() in /home/mydomain.com/public_html/shop2/update.php on line 542.
Comment #12
v1nce commentedThe attached patch fixes this issue and uses exact code from filefield.js (filefield module 5.x-2.4).
Comment #13
svihel commentedI tested the imagefield-regex.patch patch and it didn't work for me. Should I do any more then replace the code and refresh the site?
Comment #14
jhung commentedFor those not willing to wait for an official patch, replacing line 14 with the recommendation in the original post fixes this problem for me.
Comment #15
lelizondo commentedcan you tell us exactly what the new line will look like? thanks
Comment #16
drewish commentedsee #357903: JavaScript on Imagefield won't upload image files for essentially the same patch with tiny improvement in formatting.
Comment #17
codenamerhubarb commentedThanks pathfinderelite, that seems to have fixed my problem.