Yii Framework Forum: Fancyupload and mime types - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Fancyupload and mime types Rate Topic: -----

#1 User is offline   Giordano 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 07-March 10

Posted 19 April 2010 - 02:58 PM

Hi all,

I'm using FancyUpload to upload an image on a local MAMP installation.
I'm having trouble getting the right mime type using CFileHelper::getMimeType() as illustrated in the example that goes with the extension. Here's a few lines from that:



 switch(CFileHelper::getMimeType($file->getTempName())){
       case 'application/zip':
           break;
 
       case 'image/jpeg':
           $info = @getimagesize($file->getTempName());
            if ($info) {
                $return['width']  = $info[0];
                $return['height'] = $info[1];
                $return['mime']   = $info['mime'];
            }
           break;


When uploading an image the mime type comes out as application/octet-stream which is not what I expected, was hoping for image/jpeg.

Does anyone have any idea what's going on here?

Cheers
0

#2 User is offline   lightglitch 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 05-January 10

Posted 21 April 2010 - 05:56 AM

Flash uploaders always send application/octet-stream in the HTTP mimetype.
You can use fileinfo (yii already supports this but you must have the extension installed) to get the uploaded file mimetype.
0

#3 User is offline   Junior - df9 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 408
  • Joined: 24-May 09
  • Location:Brazil

Posted 22 April 2010 - 05:55 AM

View PostGiordano, on 19 April 2010 - 02:58 PM, said:

Hi all,

I'm using FancyUpload to upload an image on a local MAMP installation.
I'm having trouble getting the right mime type using CFileHelper::getMimeType() as illustrated in the example that goes with the extension. Here's a few lines from that:



 switch(CFileHelper::getMimeType($file->getTempName())){
       case 'application/zip':
           break;
 
       case 'image/jpeg':
           $info = @getimagesize($file->getTempName());
            if ($info) {
                $return['width']  = $info[0];
                $return['height'] = $info[1];
                $return['mime']   = $info['mime'];
            }
           break;


When uploading an image the mime type comes out as application/octet-stream which is not what I expected, was hoping for image/jpeg.

Does anyone have any idea what's going on here?

Cheers



Hey,

It is my fault, I should've updated the documentation and code for the extension

Try using $file->getName()

Please, see the topic
http://www.yiiframew...__fromsearch__1

There are some fixes discussed that could help you for a while

I'll try to update the extension and docs today.

Regards!!
______________________________________
Junior
df9.com.br
Linux Registered User #364954
GNU/Linux: together we're ready!
0

#4 User is offline   Junior - df9 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 408
  • Joined: 24-May 09
  • Location:Brazil

Posted 30 April 2010 - 11:12 AM

Hey, guys, I've updated the fancyupload extension, please check version 1.3 working samples and instructions file

Regards!!
______________________________________
Junior
df9.com.br
Linux Registered User #364954
GNU/Linux: together we're ready!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users