Welcome Guest, Not a member yet? Register   Sign In
help convert php to codeingter
#2

[eluser]Danes[/eluser]
Hi runrun,
This is my quick attempt at your request. It worked for me, although I'm sure it's not the tidiest way to handle it and organize the code.

I created a controller controllers/uploadcontroller.php and included the code you provided, keeping the classes defined there. Then modified the last part to define the controller class as shown here:

Code:
<?php

...

class UploadController extends Controller {
    
    // list of valid extensions, ex. array("jpeg", "xml", "bmp")
    private $allowedExtensions = array();
    // max file size in bytes
    private $sizeLimit = 8; //in MB

    private $uploader;
    
    function __construct() {
        parent::Controller();
    }
    
    function index() {
        $this->uploader = new qqFileUploader($this->allowedExtensions, $this->sizeLimit * 1024 * 1024);
        $result = $this->uploader->handleUpload('uploads/');
        // to pass data through iframe you will need to encode all html tags
        echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
    }
}

Note that to use this you will need to enable query strings as explained here.

On the client side, when creating the upload control, change the action to post to your new upload controller like this:

Code:
var uploader = new qq.FileUploader({
      element: document.getElementById('file-uploader'),
      allowedExtensions: [],
      debug: true,
      // path to server-side upload script
      action: 'index.php?c=uploadcontroller&m=index'
});

As said, no doubt the code should be separated to different files and included, perhaps, as a library, but this is a quick fix.

Hope it helps.

Regards


Messages In This Thread
help convert php to codeingter - by El Forum - 01-02-2011, 10:23 PM
help convert php to codeingter - by El Forum - 01-03-2011, 09:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB