• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with PHP response to flash uploader


I have successfully gotten image uploads and resize to work with the class from this post:

But I'm facing some issues

What should happen:

My (custom) flash uploader should read a response from PHP and then in turn call a JS function, which will display the newly uploaded image.

What happens:

The flash does not always (but does occassionaly) read the response, so the js function isn't called - even though the image does get uploaded, resized and the image info gets stored in the database.

What I've tried

I've changed the way the echo back is structured (with varying results). I've tried things like
echo 'varback1=$pieceid&varback2;=$rawname';
echo '?varback1=$pieceid&varback2;=$rawname';
echo '&varback1;=$pieceid&varback2;=$rawname';
echo 'xx=xx&varback1;=$pieceid&varback2;=$rawname';

I've played around with ini_set("memory_limit")

I've loaded the libraries and models in different places

I've also created a testing html upload form which directs the image to the same controller which works perfectly, the image uploads, gets resized, and the image info is stored. But unlike when i upload in flash, i can see the echoed response on the upload page.

I've been stuck on this for nearly 3 days now (12+ hours per day!), but still no joy.. + I've tried everything i can think of. It's such a strange error.

I'm really hoping one of you guys have come across something similar before.

Do you think it could be possible that CodeIgniter is trying to redirect to an error page, which causes no response to be echoed? If so, is there any way for me to see that error?

This is my controller:

function ddPieceUploaderImage()
        $userid = $this->input->post('Name');
        $folderid = $this->input->post('var1');
        $projectid = $this->input->post('var2');
        // set up some stuff for the uploader
        $aCfg = array();
        $aCfg['upload_path']      = '../../folder/media/image/';
        $aCfg['allowed_types'] = 'gif|jpg|jpeg|png';
        $aCfg['max_size']        = '2000';
        $aCfg['encrypt_name']    = TRUE;
        $aCfg['is_flash_upload'] = TRUE; // i do have a flash-upload with application/octet-stream instead of image/jpg
        //echo "4";
        //echo "5";  

        // filedata is the name of the file-input field / ie. form
        if ( $this->upload->do_upload('Filedata') == FALSE )
            // there is an error when uploading the file
            log_message('error', 'Flas Upload: error uploading the image: '.$this->upload->display_errors());
            echo "error";
        } else {
            $fInfo = $this->upload->data();
            $rawname                 = $fInfo['raw_name']; // name of file without extension
            $data['piecetypeid']     = 1; // 1 = image
            $data['userid']             = $userid;
            $data['projectid']         = $projectid;
            $data['position']         = $this->piece_model->getNextPosition($projectid); // get next piece position
            $data['url']             = $rawname;
            $data['title']             = $fInfo['orig_name']; // to do
            $data['datetime']         = time();
            $pieceid                 = $this->piece_model->addPiece($data,$userid); // get next piece position

            $this->_createLargeImage($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext']);
            //80x80 thumb
            $this->_createThumb($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext'],$fInfo['image_width'],$fInfo['image_height'],80);
            //132x132 thumb
            $this->_createThumb($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext'],$fInfo['image_width'],$fInfo['image_height'],132);
            //272x272 thumb
            $this->_createThumb($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext'],$fInfo['image_width'],$fInfo['image_height'],272);
            //406x180 folder thumb
            $this->_createThumb($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext'],$fInfo['image_width'],$fInfo['image_height'],406, TRUE);
            //406x180 rollover thumb
            $this->_makeRollOverThumb($fInfo['file_name'], $fInfo['raw_name'], $fInfo['file_ext'],$fInfo['image_width'],$fInfo['image_height']);            
            echo "varback1=$pieceid&varback2;=$rawname";

Have you tried doing the post back response in JSON and then reading the JSON vars in the javascript? Example of what your result would be is:


you can read more here: http://en.wikipedia.org/wiki/JSON

Hi Chris,

thanks for the reply. I never thought of using JSON for this, might have been a good idea.

I was using the FlashTracer plug-in for Firefox to read the PHP response but it acted strangely and although the files uploaded and resized, the response didn't come...

But, I got the solution about 2 hours ago. Basically I was just trying things at random and the last thing i tried was adding these lines to php.ini:

upload_max_size: 50M
post_max_size: 50M
max_execution_time = 120
max_input_time = 180
memory_limit: 32M

I think the issue was either max_execution_time or max_input_time, i havn't narrowed it down yet. I'll post back when i know which one it is

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.