Blueimp jQuery File Upload plugin with Codeigniter step by step?
Asked Answered
G

2

6

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?

Gabon answered 13/3, 2013 at 0:33 Comment(0)
B
8

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.

Buccinator answered 13/3, 2013 at 21:57 Comment(2)
where'd the conversation go? interested to get similar helpTwelvemo
I am looking for this plugin in codeIgniter. The example that comes with the demo of jquery upload is complete but is very difficult for me. I am not sure if i will be able to implement a library / helper to use it. However meantime there is always iframe to use. you can keep the standalone uploader and call it inside an iframe in your app. The catch is you have set the path/url properly in the script and dont forget to verify sessionCode
V
7

@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

Volunteer answered 3/10, 2013 at 13:23 Comment(1)
Hi, I've followed your instructions and works pletty food! Thank you very much! and Siniša of cource :).. I have one question thought I'd like to ask. how can I set dynamicly the folder to upload images in here $this->options = array('upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/uploads/albums/'. <ALBUM-NAME-HERE> ??? is there a way to pass the folder name in here?Technical

© 2022 - 2024 — McMap. All rights reserved.