Welcome Guest, Not a member yet? Register   Sign In
C:\fakepath breaks file upload?
#1

[eluser]seth.aldridge[/eluser]
Hi,

I've got a site and today my clients gave me a call and said the File Upload feature wasn't working. Turns out that IE8 and Chrome have implemented the HTML5 stuff that's breaking the upload for some reason.

I am not using the newest version of CI, but I can't easily update at the moment as the developer who helped me set this site up made all the models and controllers in the same files so the code is a mess.

I'm using 100% CI to do the upload and everything I can tell says it's related to JavaScript. Can anyone help me figure out if this is a library bug or if I'm doing something unique.

The Controller:
Code:
function save()
    {
        
        $this->db->escape($_POST);
        $this->load->library('ftp');
        $this->load->helper('file');
        
        // Had error with b_id not being found on longer videos.
        if(isset($_POST['b_id']))
        {
            $b_id = $_POST['b_id'];
        }
        else
        {
            $b_id = $this->session->userdata('b_id');
        }
                        
        $sql = "SELECT strm_password, strm_user, strm_host FROM business WHERE id = ".$b_id;
        $query = $this->db->query($sql);
        $row = $query->row();
    
        $file = $_POST['thefile'];

        $config['upload_path'] = './file_q/';
        $config['allowed_types'] = 'flv';
        $config['overwrite'] = TRUE;
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload() )
        {
            $error = $this->upload->display_errors();
            echo $error;
        }    
        else
        {
            $config['hostname'] = $row->strm_host;
            $config['username'] = $row->strm_user;
            $config['password'] = $row->strm_password;
            $config['debug'] = TRUE;
            $config['overwrite'] = TRUE;
            $this->ftp->connect($config);
            $this->ftp->upload('./file_q/'.$file, '/streaming/'.$file, 'auto');
            $this->ftp->close();
            
            redirect('video/add','refresh');
        }
    }

The HTML:
Code:
<form action="/video/save" enctype="multipart/form-data" method="post" class="video/upload">
    <input onchange="this.form.thefile.value=this.value" type="file" id="userfile" name="userfile" />
    <input name="thefile" id="thefile" type="hidden" />
</form>

The Error:

An Error Was Encountered
Unable to locate the source file. Please check your path.


The Path:
C:\fakepath\.file_q\filename.flv

Is there a quick fix for this issue?
#2

[eluser]InsiteFX[/eluser]
It has nothing to with HTML5!

This error is caused by new browses because they found a NULL bug in jQuery which Microsoft got jQuery to fix! I think this bug affected all javascript libraries.

I would try updating to the newest jQuery 1.6.1 and see if it fixes your problems.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB