views:

491

answers:

2

hi people, my file form element is very simple:

$this->archivo = new Zend_Form_Element_File('archivo');
$this->archivo->setLabel('Archivo:')
        ->setRequired(true)
        ->setDestination(UPLOAD_PATH)
        ->addValidator('Count', false, 1)
        ->addValidator('Size', false, MAX_FILE_SIZE)
        ->addValidator('Extension', false, Cobico_Form_Multimedia_SubirArchivo::EXTENSIONES_PERMITIDAS);
$this->addElement($this->archivo);

but, when uploading the file (uploads OK), I try to obtain the MIME type but for every file is the same:

$form->archivo->getMimeType()

It always returns application/octet-stream, no matter what kind of file I'm trying to upload.

Why is this happening, did I miss something in the way? Thanks

A: 

An Octet-Stream is generally any file that must be opened in another application. See:

http://kb.iu.edu/data/agtj.html

A MIME attachment with the content type "application/octet-stream" is a binary file. Typically, it will be an application or a document that must be opened in an application, such as a spreadsheet or word processor. If the attachment has a filename extension associated with it, you may be able to tell what kind of file it is. A .exe extension, for example, indicates it is a Windows or DOS program (executable), while a file ending in .doc is probably meant to be opened in Microsoft Word.

Chacha102
A: 

The most likely reason for this is that if neither the fileinfo or mime_magic extensions are available in your PHP installation, the underlying method you're using will fallback to a default mimetype:

if (empty($result[$key])) {
    $result[$key] = 'application/octet-stream';
}

Suggest you check the getMimeType() method within Zend_File_Transfer_Adapter_Abstract - where that snippet is from and called from within Zend_Form_Element_File::getMimeType() - for details, and then check what extensions you have installed and rectify appropriately.

Simon Christian