Welcome Guest, Not a member yet? Register   Sign In
swfupload problems!
#4

[eluser]Chris Newton[/eluser]
I gave up on swfupload. I MUCH prefer the following:
http://don.citarella.net/index.php/actio...-uploader/
I found it to be simpler & more reliable on all counts. It can't be styled with CSS, which is (as far as I'm concerned) is no big deal anyway. I created a CI specific version of that where all of the error reporting is handled by javascript on page, so basically the flash just needs styling changes from site to site. Unfortunately, I don't have that in a format that's easy to digest (yet) and I'm at the tail end of the gigantic project that required me to figure this stuff out in the first place so I have little time to spare.

That being said. Here's what I have for swfupload (which btw, does not work on MOSSO host, but works just fine on Dreamhost, and several other hosts) This was some dev code, so there's some dumb stuff still in here.

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

class Create extends Controller
{
    function Create()
    {  
        parent::Controller();
        // Keeping the image sizing consistent
        $this->image_config_width                =    458;
        $this->image_config_height                =    649;    
        $this->image_preview_width                =    711;
        $this->image_preview_height                =    1008;    
    }
    /**
     * Image uploader
     *
     * Aids in the uploading & storage of images for
     * later manipulation. If used with SWFUpload the
     * fieldname must be Filedata
     *
     * @param    string $fieldname    ID of the input field uploading image/file. MUST BE 'Filedata' to work with SWFUpload
     * @param    bool $flash    optional, if FALSE, data will be returned, rather than echo'd.    
     * @access    public                                                        
     * @return array or echo
     */    
    function upload_image($fieldname='Filedata', $flash=TRUE)
    {  
        if (isset($_POST["PHPSESSID"])) {
            session_id($_POST["PHPSESSID"]);
        }
           // The upload function has a common configuration file with filesize, min, max settings

        $this->config->load('upload');
        $this->load->library('upload');

        $this->load->library('phpsession');
        $this->load->helper(array('url'));
        
        // Starting a session to find the ID of the page that uploaded the file
        $session_id = session_id();

        // FAILED UPLOAD
        if (!$this->upload->do_upload($fieldname))
        {
            $data['result']            =    'failure';
            // must start with 'error'for the javascript error reporting to work correctly.
            $data['errors']            = 'error|';
            $data['errors']            .=    $this->upload->display_errors('', '|');

            if ($flash)
            {
                echo $data['errors'];
            }

        }
        // SUCCESSFUL UPLOAD    
        else
        {  
            $upload_data            =    $this->upload->data();
            $data['result']            =    'success';
            $data['file_name']        =    $upload_data['file_name'];
            $data['file_path']        =    $upload_data['file_path'];            

            if ($flash)
            {
                // flash must receive a message to achieve 'success'. Javascript handlers can be used to override this data's output
                echo $data['file_name'];
            }
            else
            {
                echo "error|copying the uploaded file failed";
            }
            // saving the filename to session so that the filename can be picked up by the next script
        }
        if (!$flash)
        {
            return $data;
        }
        else
        {
            return 'A flash error has occurred #1002';
        }
        
    }  
}


Messages In This Thread
swfupload problems! - by El Forum - 09-10-2008, 04:25 PM
swfupload problems! - by El Forum - 09-10-2008, 06:53 PM
swfupload problems! - by El Forum - 09-10-2008, 09:09 PM
swfupload problems! - by El Forum - 09-11-2008, 04:04 AM
swfupload problems! - by El Forum - 09-11-2008, 04:04 AM
swfupload problems! - by El Forum - 09-11-2008, 04:04 AM
swfupload problems! - by El Forum - 09-11-2008, 04:14 AM
swfupload problems! - by El Forum - 09-11-2008, 04:23 AM
swfupload problems! - by El Forum - 09-11-2008, 08:02 AM
swfupload problems! - by El Forum - 09-11-2008, 09:48 AM
swfupload problems! - by El Forum - 09-11-2008, 09:54 AM
swfupload problems! - by El Forum - 10-31-2008, 07:27 PM
swfupload problems! - by El Forum - 11-15-2008, 04:13 PM
swfupload problems! - by El Forum - 11-18-2008, 04:34 PM
swfupload problems! - by El Forum - 11-18-2008, 05:28 PM
swfupload problems! - by El Forum - 11-18-2008, 06:53 PM
swfupload problems! - by El Forum - 11-18-2008, 06:56 PM
swfupload problems! - by El Forum - 11-19-2008, 03:28 AM
swfupload problems! - by El Forum - 11-19-2008, 08:27 AM
swfupload problems! - by El Forum - 11-24-2008, 04:01 PM
swfupload problems! - by El Forum - 11-25-2008, 05:07 AM
swfupload problems! - by El Forum - 11-25-2008, 03:46 PM
swfupload problems! - by El Forum - 04-20-2010, 08:49 AM
swfupload problems! - by El Forum - 04-20-2010, 08:54 AM
swfupload problems! - by El Forum - 04-20-2010, 09:09 AM
swfupload problems! - by El Forum - 04-20-2010, 09:15 AM
swfupload problems! - by El Forum - 04-20-2010, 09:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB