Quantcast
Channel: Squirrel Hacker » Code Igniter
Viewing all articles
Browse latest Browse all 4

Using Valums File Uploader with CodeIgniter

$
0
0

Valums file uploader is a fancy pants ajaxy uploader widgit that is meant to be used with normal php pages. It, by default, doesn’t really play well with CodeIgniter.

Fortunately, it isn’t that hard to make it work. There is a bit of a modification to the .js file:

Basically, you just have to turn the ?qqfile=blah into /blah . Granted, this is a quick fix… and it will not work if you want to pass extra params to the upload. A better fix would be to rewrite parts of the qq.obj2url function so that it accepts a different separator.

The other thing you have to worry about is CodeIgniter’s magical stripping of characters that it doesn’t like specifically: the . in your file’s name. Fortunately this is easy to fix:

//snip [......]
	  //codeigniter replaces the . with a _ argh, we can fix that by doing this:
	  $filename = substr_replace($param1, '.', strrpos($param1, '_'), strlen('_'));
//[......]   /snip

That is about it, the code is available here: https://github.com/SeanJA/uploadr.

Also, since I don’t subscribe to the “we must support php 4 forever” mentality, you will notice that the methods in my classes have private, public, and protected, you can just remove all of those if you need to support PHP 4 still (but you really should upgrade…).

flattr this!


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images