Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blueimp jQuery File Upload plugin with Codeigniter step by step?

https://github.com/blueimp/jQuery-File-Upload I spend 2 days on this, and nothing worked. I also downloaded the example from their site (https://github.com/blueimp/jQuery-File-Upload/wiki/jQuery-File-Upload-6.5-with-CodeIgniter-2.1), but it gives syntax which I can't fix because everything seems normal in the code, and my editor also doesn't find any syntax error... On the other, the code on the example page is different from the code in the .zip that they offer to download.

The original demo works fine, but I can't integrate it into CodeIgniter, I don't know how to handle everything I need. By default it loads all the files from the directory, and I don't need that. For adding product in the admin, the list should be empty, and the files should be uploaded in a directory like this /pictures/month/filename.ext and during the upload it should create 3 sizes of thumbnails /pictures/th1/month/filename.ext For editing product, I need to load previously loaded images from the database for the specific product, not all of the pictures in the folder. And last, the Delete function doesn't delete the images.

As I can see the images are uploaded without sending the form, right? It's important because I have 10 other input fields for product details that need to be send with sending the form and stored in the database. Everything is done and working except for the image gallery with this plugin.

Can someone help me through this?

like image 822
MarkC Avatar asked Mar 13 '13 00:03

MarkC


2 Answers

At the first place, sorry for my bad english. I don't know are you still interesed about this topic. Never mind, let this be hint for next visitors.

Don't follow tutorial about codeigniter integration, it's to complicate to figure it out from uncomplete code, rather, get demo source and build a solution from that point. I did it in 1 hour :)

You have to make a Codeigniter library of UploadHandler.php according to the doc. Inside librarys __construct() function change script_url value to absolute path to controller you'll create.

Than, create controller and load library inside index function.

Edit main.js file, replace content of url: "server/php" in $('#fileupload').fileupload() function to name of your controller.

Now you can create another controller and load a view with content of index.php from original demo.

If you do all I specified, you should be able to use first controller to make ajax calls from second controller.

like image 87
Siniša Avatar answered Nov 19 '22 15:11

Siniša


@Sinisa proved the valuable pointer. I could make version Fileuploader 8.8.5 work with CI 2.1.3 with relative ease. I have updated the wiki - here is a link:

https://github.com/blueimp/jQuery-File-Upload/wiki/Jquery-file-upload-8.8.5%2Cwith-codeigniter-2.1.x

like image 37
dipan66 Avatar answered Nov 19 '22 17:11

dipan66