AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Some attached files fail to download
 
 

Andrew Smith has a post (found here) in which he attached 2 files:

1.) eng.grammar
2.) the-country-of-the-blind.xml.zip

The zip file downloads quite well, with no problems at all, but the other file’s link just opens a blank page. I’ve tried several times to download the file in different ways (e.g. same page, new window/tab, “save location as…”) with basically the same result. Just a blank.

I suspect that this is due to a failure in the script to determine the correct mime-type for the file, and so simply dies without any output. If this is the case, perhaps assigning the mime-type “text/plain” may resolve the situation with a minimum of hassle. I realize that there will be times when this approach will give unexpected results, but it’s better by far than having folks get a blank page for their efforts. smile

I’ve suggested to Andrew that he either zip the file and attach the zip file, or change the extension of the file to .txt and try it again. The second method would be best (renaming the file), as it will possibly help to diagnose the problem.

 

 
  [ # 1 ]

By the way, I’ve tested out my theory, by attaching the same file (Andrew was kind enough to provied it in a zip file), but with a .txt extension, to a subsequent post in the same thread, and that file can be downloaded just fine.

 

 
  [ # 2 ]

OK, we’re pretty protective on uploading files, as we’ll need to be able to test them against viruses, to protect our visitors and to make sure we are not fined by search engines because we are offering ‘bad’ content. So I think we’ll never accept ZIP’s. People just need to upload their files. Would that work? Do you have a suggestion for an additional explanatory line?

 

 
  [ # 3 ]
Dave Morton - Nov 26, 2011:

I suspect that this is due to a failure in the script to determine the correct mime-type for the file, and so simply dies without any output. If this is the case, perhaps assigning the mime-type “text/plain” may resolve the situation with a minimum of hassle.

Yes, the problem here is that ExpressionEngine doesn’t know what to do with the .grammar extension. It already uses the “text/plain” mime-type for other extensions, such as .log and .txt ... but .grammar is unknown.

I have just added .grammar to ExpressionEngine’s MIME types configuration file and now the file in this post downloads just fine.

But I am not sure if adding .grammar is such a good idea. Where does this end? There can be an infinite number of extensions in this manner.

The best solution should be to simply upload text files with a .txt extension. The poster should rename the file to eng.grammar.txt and if necessary explain what to rename it to. Alternatively the file(s) can be zipped.

Erwin Van Lun - Nov 28, 2011:

So I think we’ll never accept ZIP’s. People just need to upload their files. Would that work? Do you have a suggestion for an additional explanatory line?

ExpressionEngine’s Discussion Forum module accepts all file type attachments. There is a setting: Images Only or All File Types. There is currently no option to not accept ZIP files.

 

 
  [ # 4 ]

Is there a way to simply treat unknown file extensions as “text/plain”, rather than adding mime-types? It seems to me that this may be simpler than adding new mime-types as they’re encountered.

Since my desktop crashed, I haven’t had the opportunity to obtain the login data for the sandbox, so I’ve not been able to investigate the code for myself, so that I might make a more specific suggestion. I’ll look through my past emails and find the login data, so that I might do just that. smile

The vast majority of Anti-Virus scanners are able to scan files within compressed package files (e.g. zip, cab, rar, etc.), so zip files themselves shouldn’t really be an issue from that standpoint. As long as the attachment script automatically scans them upon successful upload, and both removes infected files and notifies the admin staff of any infections and their sources, then no file of any type should be a concern, except for perhaps size. smile

 

 
  [ # 5 ]
Dave Morton - Nov 28, 2011:

Is there a way to simply treat unknown file extensions as “text/plain”, rather than adding mime-types?

I don’t know if this is possible in ExpressionEngine and whether this is safe. If you’d like please have a look in your sandbox environment. The EE mime types are defined in file config/mimes.php.

You can find more information about EE mime types and upload preferences in the user guide: http://expressionengine.com/user_guide/cp/content/files/file_upload_preferences.html

Thanks

 

 

 
  login or register to react