Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Allowed file types or other problem with the files


Reply


8 Posts   3890 Views

Avatar
Carrie_Lang

Community Member, 24 Posts

5 April 2011 at 7:48am

Where do I find the part of the code that shows allowed file types/extensions to be uploaded..? I once looked it, but now I don't find. I need to check if the djvu-files are allowed, because now I can't upload those in Files & Images. Or is the problem somewhere else, because the upload starts right (but when the bar reaches 100 % an error appears)?

The problem is that I can't open even those files that are transfered by ftp. When trying to open the file with the straight address it says "access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server."

Avatar
LostBalloon

Community Member, 16 Posts

16 April 2011 at 8:32am

Yeah,

Same problem here, i read somewhere that there is a way to change what file types are allowed, but i cant find how yet.
I'd like to know as well.

Plus, on my side, SS is blocking my <embed> tag from appearing for some reason (its added dynamically and the code works when im not on silverstripe)

Avatar
martimiz

Forum Moderator, 1132 Posts

16 April 2011 at 10:26pm

Edited: 16/04/2011 10:28pm

One reason could be the filesize: php can only upload up until a certain (php.ini) filesize (mostly about 2MB) It doen't know the filesize in advance, so upload will start, but then just not be completed. Follow a similare discussion here:

http://www.silverstripe.org/dataobjectmanager-module-forum/show/13243

Next: SiverStripe has predefined a hughe number of file extensions as acceptable for upload, but djvu is not part of them. Look in /sapphire/FileSystem/File.php. Instead of hacking this file, you can try defining your own list of acceptable extensions in /mysite/_config.php and add the djvu to them (I just copied the whole list, but you could customize it). That seems to do the trick...

File::$allowed_extensions = array(
      '','html','htm','xhtml','js','css',
      'bmp','png','gif','jpg','jpeg','ico','pcx','tif','tiff',
      'au','mid','midi','mpa','mp3','ogg','m4a','ra','wma','wav','cda',
      'avi','mpg','mpeg','asf','wmv','m4v','mov','mkv','mp4','swf','flv','ram','rm',
      'doc','docx','txt','rtf','xls','xlsx','pages',
      'ppt','pptx','pps','csv',
      'cab','arj','tar','zip','zipx','sit','sitx','gz','tgz','bz2','ace','arc','pkg','dmg','hqx','jar',
      'xml','pdf','djvu',
   );

Third: in the assets folder there is a web.config file, that also contains a list of extensions. As I understand it, this doesn't restrict uploads for other filetypes, but could prevent them being displayed in the frontend. Maybe you should add the extension here as well (haven't tested this)...

Avatar
Carrie_Lang

Community Member, 24 Posts

5 May 2011 at 6:50am

But can the problem be with the upload size, because there's problem as well as those files that are transfered by ftp? I added djvu to allowed extensions (both places), but that didn't help. Where should I find the php.ini file?

Avatar
Carrie_Lang

Community Member, 24 Posts

21 June 2011 at 2:30am

The upload problem I don't have anymore, I tested and the djvu file uploading works fine now. But the files are still not reachable from the site, Access forbidden message appears when trying to open link to the djvu file..

Avatar
Plato

Community Member, 26 Posts

21 June 2011 at 9:40am

Carrie_Lang: Did you modify your assets/.htaccess file?

martimiz:
As far as I understand it, web.config is the Microsoft IIS version of Apache's .htaccess, and should not have any effect on sites not hosted on any other web server.

Avatar
Carrie_Lang

Community Member, 24 Posts

21 June 2011 at 9:49pm

Ok, that's the file I missed, and the problem is fixed (how poetic..) Thanks :)

Now I just need to search some topics for an answer to the question about SecureFiles. When I put the folder with those files secured with Secure files module, an error appears with the message "Forbidden - The website server has not been able to respond to your request."

Avatar
Spambanjo

Community Member, 17 Posts

2 October 2012 at 1:42am

Edited: 02/10/2012 1:43am

Hi, sorry to reply to such an old topic, but I stumbled on this thread and found the solution suggested was not acceptable for me. I wanted to post my solution here as it was inspired by martimiz's reply and may help someone else in the future.

I am developing a very simple module (my first ever) to make use of the [url=http://camendesign.com/code/video_for_everybody]"Video for Everybody" HTML5 video embed code by Camen Design[/url] within Silverstripe. I needed to add a couple of filetypes which are currently not supported by the CMS, namely "webm" and "ogv" video file formats (ogg is supported by Silverstripe, but not ogv or oga).

My solution to the problem was to add the following lines to my module's _config.php:

File::$allowed_extensions[] = 'webm' ;
File::$allowed_extensions[] = 'ogv' ;

I wanted to automate as much as possible without the user needing to edit any system files, but I still need to have them manually edit the .htaccess files unfortunately (one for the VFE code in root and another for the filetypes in /assets/.htaccess)