• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using SWFUpload + Sessions + upload class, how I did it.

Use the built-in logging class:

thanks, i have it all working except i can no longer get the user_id from $this->dx_auth->get_user_id() but i will work on that

got it all working, thanks for your help.

[quote author="CollinsSolutions" date="1236910804"]got it all working, thanks for your help.[/quote]

How please? I am trying to get swfupload to work with dx_auth. What did you do exactly?

$user_id = $this->uri->segment(3);
    //print('User ID:'.$user_id);
    $upload_name = 'Filedata';
    //echo $count;
    //log_message('info', 'Just inside loop');
        $fileName = $_FILES[$upload_name]['name'];
        //echo 'Name is: ' . $fileName . '<BR>';
        //log_message('info', $this->dx_auth->get_user_id());
        $file = array(
        'name' => addslashes($fileName),
        'type' => $_FILES[$upload_name]['type'],
        'size' => $_FILES[$upload_name]['size'],
        'user_id' => $user_id);
        $tmpName  = $_FILES[$upload_name]['tmp_name'];
        $content = read_file($tmpName);
        $content = addslashes($content);
        $file['content'] = $content;
        $this->db->insert('files', $file);
I was inserting into a database so the code was less than uploading. And i used the following for the swf code
var swfu;

        window.onload = function() {
            var settings = {
                flash_url : "&lt;?=$url?&gt;flash/swfupload.swf",
                upload_url: "&lt;?=$site_url?&gt;/manage/do_upload/&lt;?=$this->dx_auth->get_user_id()?&gt;",    // Relative to the SWF file
                post_params: {"PHPSESSID" : "&lt;?=$this->session->userdata('session_id')?&gt;"},
                file_size_limit : "100 MB",
                file_types : "*.pdf",
                file_types_description : "Only PDF",
                file_upload_limit : 100,
                file_queue_limit : 0,
                custom_settings : {
                    progressTarget : "fsUploadProgress",
                    cancelButtonId : "btnCancel"
                debug: false,

                // Button settings
                button_image_url: "&lt;?=$url?&gt;images/TestImageNoText_65x29.png",    // Relative to the Flash file
                button_width: "65",
                button_height: "29",
                button_placeholder_id: "spanButtonPlaceHolder",
                button_text: '<span class="theFont">Browse</span>',
                button_text_style: ".theFont { font-size: 16; }",
                button_text_left_padding: 6,
                button_text_top_padding: 3,
                // The event handler functions are defined in handlers.js
                file_queued_handler : fileQueued,
                file_queue_error_handler : fileQueueError,
                file_dialog_complete_handler : fileDialogComplete,
                upload_start_handler : uploadStart,
                upload_progress_handler : uploadProgress,
                upload_error_handler : uploadError,
                upload_success_handler : uploadSuccess,
                upload_complete_handler : uploadComplete,
                queue_complete_handler : queueComplete    // Queue plugin event

            swfu = new SWFUpload(settings);

Thank you for posting that, however my problem is more checking if a user is logged in at the top of my controller:

class Files extends Controller {

    function files()
        // Ensure user is logged in
        if (!$this->dx_auth->is_logged_in())  
            // Redirect to login page
            redirect('/auth/login/', 'refresh');

I can't seem to pass the session id properly from the flash to ensure the user is logged in. If I remove my if statement above, it works fine of course and posts.

Any ideas?

What session library do you use?
If it's CI session, have a look at http://ellislab.com/forums/viewreply/536121/.

post_params: {"PHPSESSID" : "&lt;?=$this->session->userdata('session_id')?&gt;"},

also make sure you have

up top

I am using dx_auth, which seems to use ci sessions, but it stores them in the database. It autoloads ci's session library as well in their class.

The problem is I have the check on the entire controller, (files) but I'm posting to /files/do_upload/ on my controller. I need some way to pass the session to the construct (using post or get) and passing that to dx_auth somehow...I'm fairly new to CI so not 100% sure how sessions are handled, it is surely cookie based though.

The instructions at the top of this (editing Session.php) are outdated it seems as well, the code isn't the same, nor are the line numbers.

I do have the proper session ID on my form page, using the technique above, but whenever I post a new flash session is added to the database and just adding it to session_id() in my construct doesn't seem to work correctly with dx_auth.

So I'm a bit stuck at the moment.

you can set the session id by getting the PHPSESSID post param.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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