Part of the EllisLab Network
   
1 of 2
1
Dont uploading flv file
Posted: 29 October 2007 10:22 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  20
Joined  08-08-2007

$config[‘upload_path’] = ‘uploads/images/’;
$config[‘allowed_types’] = ‘flv’;
$config[‘max_size’] = ‘99920439’;
$config[‘max_width’] = ‘1024’;
$config[‘max_height’] = ‘768’;

$this->load->library(‘upload’, $config);

$this->upload->initialize($config);

$this->upload->do_upload(‘videofile’);

Result: print_r($this->upload->data());

Array
(
  [file_name] => habibi.flv
  [file_type] => application/octet-stream
  [file_path] => x:/home/yaba.by/www/uploads/images/
  [full_path] => x:/home/yaba.by/www/uploads/images/habibi.flv
  [raw_name] => habibi
  [orig_name] =>
  [file_ext] => .flv
  [file_size] => 7382.4
  [is_image] =>
  [image_width] =>
  [image_height] =>
  [image_type] =>
  [image_size_str] =>
)

wtf ):

Profile
 
 
Posted: 30 October 2007 07:38 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  332
Joined  09-11-2007

i founded the same “problem”

go to application/config/mimes and put the extension (flv) and the type in that file. will work, believe me

 Signature 

cool mad
Rafael
Last.fm
Twitter

“Because they’re stupid, that’s why. That’s why everybody does everything!”

Profile
 
 
Posted: 30 October 2007 10:09 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  216
Joined  10-25-2007

the proper mime type for .flv is “video/x-flv”

Profile
 
 
Posted: 30 October 2007 10:18 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Avatar
Rank
Total Posts:  81
Joined  06-25-2007

$mimes = array(

‘flv’  =>  ‘application/octet-stream’

);

 Signature 

Masssss….........
Please always help to others….at any time

Profile
 
 
Posted: 30 October 2007 11:39 AM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4785
Joined  07-14-2006
MASS MASS - 30 October 2007 02:18 PM

$mimes = array(

‘flv’  =>  ‘application/octet-stream’

);

If that isn’t uploaded with IE i’m losing my faith in browsers.

Profile
 
 
Posted: 31 October 2007 10:12 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Avatar
Total Posts:  20
Joined  08-08-2007

Thx’s!

Profile
 
 
Posted: 04 December 2007 12:10 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  7
Joined  09-26-2007

I’ve got the same problem, however the fixes that seem to work for everyone else do not seem to be working for me.

I have tried adding all three of the following to the mimes array in mimes.php

'flv'    =>    'video/x-flv'
'flv'    =>    'application/octet-stream'

and

'flv'    =>    array('video/x-flv''application/octet-stream'), 

and it still doesn’t work [The filetype you are attempting to upload is not allowed]

does anyone know what I could be missing? Is there another fix to this?

CodeIgniter version 1.5.3

Profile
 
 
Posted: 10 December 2007 12:27 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  7
Joined  09-26-2007

Well it looks like I’m going to have to do this the standard php way.
It’s a shame that the code igniter upload library is so unusable. I’ve never encountered a problem with a ci library that has forced me to completely bypass it like this.

Profile
 
 
Posted: 10 December 2007 01:32 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  269
Joined  09-13-2007

Well I don’t think this is a problem with CI since I have a site where the standard code for upload works fine for uploading the flv files. Once you add the mime type the file should be easily uploaded without anything else required. Please provide info about your setup or maybe the code for uploading. Someone might get some clue from it.

Good Day !!!

 Signature 

Sarfaraz Momin.
PHP With Us

Profile
 
 
Posted: 10 December 2007 07:46 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  7
Joined  09-26-2007

Thanks for replying.

I’m pretty sure that I’ve got everything right as far as my code goes.

$config['upload_path''./uploadedfiles';
$config['allowed_types''flv|zip';
$this->load->library('upload');
$this->upload->initialize($config);
if (
$this->upload->do_upload()) 

I can upload zip files ok. It’s just .flv

[php5 | apache 2.2.3 | opensuse 10.2 | codeigniter 1.5.3]

Profile
 
 
Posted: 21 January 2008 05:19 AM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  69
Joined  05-20-2007
kaff - 10 December 2007 05:27 AM

Well it looks like I’m going to have to do this the standard php way.
It’s a shame that the code igniter upload library is so unusable. I’ve never encountered a problem with a ci library that has forced me to completely bypass it like this.


No dear no,

It works fine, I took hints form your thread, It works fine.

Please check the directory permissions,

THanks

 Signature 

IT Outsourcing | Web Development|Cheap Hosting | Cheapest hosting | Free hosting linux

Profile
 
 
Posted: 21 January 2008 05:54 AM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  65
Joined  01-12-2008

I thought we already solved this in another thread.

Things to check:
*Make sure you actually uploaded the mimes.php file.
*Make sure the directory has write permissions
*Make sure you are not uploading a file larger than your php.ini allows
*Make sure you are using the correct form type.
*Make sure you uploaded your most current uploading script (be it a controller, library etc.)
*Make sure you actually allowed .flv to be uploaded through filters
*Make sure your form name for the file upload is the same for your validation.

There are so many places an error can happen is quite sad, but some research can bring amazing results. I bet it’s something silly you did wrong.

Profile
 
 
Posted: 30 January 2008 06:38 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  1
Joined  05-21-2007

Hey, today i figured out, that its a problem also with browsers, really.
For example: if in mimes.php i set:

'flv'    =>    array('video/x-flv''flv-application/octet-stream''application/octet-stream'), 

Firefox is uploading without problem, but Safari doesn’t. And if i set:

'FLV' =>    array('video/x-flv''flv-application/octet-stream''application/octet-stream'), 

then Safari uploads *.flv files fine, but Firefox doesn’t. So right now i’m trying in Upload.php class to recognize browser and set different mimes.php, like mimes_safari.php and mimes.php for others.

Hope it will work. Will inform after success.

UPDATE:

SOLVED! As i wrote above, it’s a problem with Safari (allowed type FLV). So in Upload.php i changed for example:

function mimes_types($mime)
{
    
if (count($this->mimes) == 0)
    
{
        
if    (!strpos($_SERVER['HTTP_USER_AGENT']'Firefox'))
        
{
            
if (@include(APPPATH.'config/mimes_safari'.EXT)) //mimes_safari is in config mimes_safari.php with [b]FLV[/b] mime type
            
{
                $this
->mimes $mimes;
                unset(
$mimes);
            
}
        }
        
else
        
{
            
if (@include(APPPATH.'config/mimes'.EXT)) // is in config mimes.php with [b]flv[/b] mime type
            
{
                $this
->mimes $mimes;
                unset(
$mimes);
            
}
        }    
    }
    
return ( ! isset($this->mimes[$mime])) ? FALSE $this->mimes[$mime];

Of course, we can do it easier in one mimes.php file with two arrays, like

$mimes = array('flv'    =>    array('video/x-flv''flv-application/octet-stream''application/octet-stream'),); 
and
$mimes_safari = array('FLV'    =>    array('video/x-flv''flv-application/octet-stream''application/octet-stream'),); 
Profile
 
 
Posted: 19 March 2008 10:02 AM   [ Ignore ]   [ # 13 ]  
Summer Student
Avatar
Total Posts:  14
Joined  01-04-2007

It appears that Safari doesn’t send/report(?) a mime type for some files. I had the same problem adding a mime type for OpenType fonts “.otf”. When I tested what the reported content-type was, Safari displayed nothing, Firefox showed application/octet-stream.

So, the way I fixed it was by adding a blank element to the array. Seems to work!

'otf' => array('','application/octet-stream'

Perhaps CI needs to patch the Upload class to look out for this sort of behavior automatically.

Update: Googling this topic uncovered others with similar issues. Safari does not send a content-type for certain files, FLVs being a prominent one.

Profile
 
 
Posted: 19 March 2008 10:35 AM   [ Ignore ]   [ # 14 ]  
Summer Student
Avatar
Total Posts:  14
Joined  01-04-2007

Another way to solve this is to extend the upload class with a small modification to the is_allowed_filetype() function. The only code I added was between the //Safari Hack comments…

<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');


class 
MY_Upload extends CI_Upload
{

    
function MY_Uplaod()
    
{
        parent
::CI_Upload();
    
}


    
function is_allowed_filetype()
    
{
        
if (count($this->allowed_types) == || ! is_array($this->allowed_types))
        
{
            $this
->set_error('upload_no_file_types');
            return 
FALSE;
        
}
             
        
foreach ($this->allowed_types as $val)
        
{
            $mime 
$this->mimes_types(strtolower($val));
        
            if (
is_array($mime))
            
{
                
if (in_array($this->file_type$mimeTRUE))
                
{
                    
return TRUE;
                
}
            }
            
else
            
{
                
if ($mime == $this->file_type)
                
{
                    
return TRUE;
                
}    
            }
        
            
// Safari Hack Here
            
if ($mime && $this->file_type == "")
            
{
                
return TRUE;
            
}
            
// End Safari Hack
        
}
    
        
return FALSE;
    
}
Profile
 
 
Posted: 19 July 2009 02:50 AM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  1
Joined  04-06-2009

This might help:

I had problems uploading flv files as well, i followed this thread, tried out a couple of stuff. Ended up editing my mimes.php file in the config folder with:

'flv'    => array('video/flv''video/x-flv''flv-application/octet-stream''application/octet-stream'), 

Just this didn’t work, when calling the upload class you need to specify the allowed file extensions, ofcourse I had flv in there, but that didn’t succeed.

When I changed that allowed file types to flv|*other file types, my flv upload started working, so it looks like you need to specify flv first.

(maybe i am doing it wrong, but this worked for me wink)

Profile
 
 
   
1 of 2
1