Welcome, Guest
Username: Password: Remember me

TOPIC: [SOLVED] file extension error

[SOLVED] file extension error 24 May 2012 15:59 #2406

  • dheyfesson
  • dheyfesson's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Thank you received: 1
  • Karma: 0
configured to accept the project extents. doc. pdf. zip and. tar.gz
but only the. pdf and. doc are working, when I send a aquivo. zip or. tar.gz the following error appears:

"Mime type not valid (application/zip), allowed Mimes are application/msword - application/pdf - application/x-gzip - application/x-zip : There were some upload errors"
Last Edit: 24 May 2012 17:10 by dheyfesson.
The administrator has disabled public write access.

Re: file extension error 24 May 2012 17:09 #2408

  • dheyfesson
  • dheyfesson's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Thank you received: 1
  • Karma: 0
I found the solution!

I edited the file file.php
function save(){
.
.
.

//UPLOAD FILE : Arquivo
if (!$this->_upload('arquivo', &$post, array(
'application/msword' => 'doc',
'application/pdf' => 'pdf',
'application/x-gzip' => 'tar.gz', /*to 'application/x-gzip' => 'gz' */
'application/x-zip' => 'zip' /*'application/zip' => 'zip'*/
)))
return;
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: file extension error 25 May 2012 00:54 #2409

  • ivojunior
  • ivojunior's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Thank you received: 2
  • Karma: 1
To get the mime type, the application uses a "switch" with some methods of php.
I test individually and saw the following:
"File_info" runs only with PHP 5.3 and my server runs the 5.2.14, ie, this method does not run for me. check your version of php!
"Mime_content_type" gives the error "Call to undefined function mime_content_type ()" which also comes from php.
These methods could identify the mime type. However, because they do not run then the system does not identify.
When they work we can get the mime type "application / octet-stream" which is a generic type. Even so, we can not identify the extent, because this type comprises various formats. To learn more, visit mimeapplication.net/octet-stream
If you want to check the mime type for files (not images) is complicated. Unless you use some library will in your php.

The solution for me was:
1 - add the list of mime, the type ('application / force-download' => 'zip').
So, every file has not set a mime will be saved with this extension.
ps.: You can replace "zip" the extension you want "docx" etc ... thus the file will be saved in this format. I sent a php file, I tried to access it but could not. I could just download the file as it was in zip format. Do not know if it ensures safety, but it's an option.

2 - If you want to send multiple formats so you should disable the checking of the mime:
classes/upload.php -> function checkMime ($fileMime) {return true;}
Then add in the list of mime types ('application / force-download-xls' => 'xls', 'application / force-download-csv' => 'csv' ... and so on)
Then rename the file in the format {ALIAS}. {EXT} (default is {MIMEXT}).
Thus, the file is sent and renamed using the original extension. Of course in any format can be sent. But apload work. What is interesting is that you do not have direct access to the file and the link can only download it. I tried to force upload a php file but not run. What is good!

Well, excuse my English ... and hope that it will be useful to someone!
The administrator has disabled public write access.
The following user(s) said Thank You: admin, edwardcox

Re: file extension error 25 May 2012 08:30 #2410

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
Thank you so much for your contribution.

First of all, for beginners who struggle and cannot get rid of mime detection issues : Desactivate it, removing the source code in the classes/file.php

AND : when you desactivate the mime, you cannot anymore use the {MIMEXT} tag for rewrite.
Use {EXT} tag

Each version of php 5.2, 5.3, Win, Unix... has different way to get the mime.
This is why you can see that your component try all theses methods one after the other.

You can copy the source code in Joomla native com_media helper, BUT be aware that the mime detection is called ONLY if some mimes has been configurated as forbidden. By default, it do not check it (if I remember well).

So, you can copy the source from com_media, and see that it is not working in your component ;-(
But, in facts this is because that source you copy from com_media it is often not called at all.

There has been some posts about that in this forum. So before thinking Cook generated wrong (wich is possible), please try a single php test outside of your component.

I want to precise also that the mimes types in Cook Builder interface are only for example. You can add as many as you want on this not exahustive list. The idea was to do not get you confuse in thousands of different and specific mime types.

I precise again that mime detection is not for security !!! (only ergonomy, and extension rewrite)
So, you can accept all the files you want while you use the indirect file access. (url call through index.php)

Hope it can help.
What is interesting is that you do not have direct access to the file
Yes. Absolutly
and the link can only download it.
Yes and no. If the mime is not an image, then it will force the download with no risk of execution.
If you call an image file you should specify in url that it is for download. If not, the image will be entirely outputed with an image header type, so you can show it. (indirect access)
I tried to force upload a php file but not run. What is good!
Yes. And even if you don't specify 'download' in url, it will force download because not allowed to execute.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: file extension error 25 May 2012 11:39 #2411

  • ivojunior
  • ivojunior's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Thank you received: 2
  • Karma: 1
I who thank you for applying!
For me it was perfect. The only difficulty I had was with this issue of the upload. But with a little research and took a look at the forum to understand what was happening.
I believe that with these posts will give help to all who pass by the same problem. Before anyone says it is problem of the application.
In fact, there is always a suspicion of such applications. But this worked perfectly. Congratulations!
Last Edit: 25 May 2012 11:39 by ivojunior.
The administrator has disabled public write access.

Re: file extension error 25 May 2012 11:58 #2412

  • admin
  • admin's Avatar
  • Online
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
In fact, there is always a suspicion of such applications. But this worked perfectly. Congratulations!

Thank your very much.
But I want to precise that Cook is far away from what we can call perfect.
The MVC does not apply the new standards of 1.6 and further 2.5.
With the old 1.5 compatibility, I had to keep a common structure understandable for 1.5 (even if your component is not really cross version because of few things), but actually the main structure is old school way of doing.

So, I am preparing the V2.0 wich will be released next month if everything fine, and finish definitively 1.5 support.
www.j-cook.pro/forum/14-news-a-chillout/2386-new-mvc-structure

By the way, people are affraid with generators because of the implementation of exotic framework and functionalities.
Cook of course add some 'way of doing' that is mine but still respect the Joomla standard (at least 1.5).
This is the meaning of 'no framework uses' in Cook.
So the source is understandable by everybody.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: file extension error 25 May 2012 13:11 #2413

  • ivojunior
  • ivojunior's Avatar
  • Offline
  • New Member
  • Posts: 7
  • Thank you received: 2
  • Karma: 1
The important thing is that the j-cook makes what to do. I created an application that would take days for just one night and now everything is running perfectly. I await the new version and hope to help as well.

regards,
The administrator has disabled public write access.
Time to create page: 0.105 seconds

Get Started