Code Monkey home page Code Monkey logo

cakephp-jqueryfileupload-plugin's Introduction

#JqueryFileUpload Plugin for CakePHP2.x (Abandoned Project) We substitute for angular-file-upload

The JqueryFileUpload Plugin provides an easy-to-use feature jQuery-File-Upload in CakePHP2.x

#Version This v1.0

Description

JqueryFileUpload Plugin for CakePHP2.x is a practical way to use the library jQuery-File-Upload

Libs

Bootstrap

Usage

Controller/AppController.php:

<?php
class AppController extends Controller {
        public $components = array('JqueryFileUpload.Upload');
        public $helpers = array('JqueryFileUpload.UploadScript', 'JqueryFileUpload.UploadTemplate');


        public function deleteFile($file) {
            $this->autoRender = false;
            if ($this->request->is('delete')) {
                $_GET['file'] = $file;
                $this->Upload->deleteFile(array('image_versions' => array('' => array(), 'medium' => array(), 'thumbnail' => array())));
            }
        }


        public function upload() {
            $this->autoRender = false;
            $this->Upload->uploadFile(array(
                'image_versions' => array(
                    '' => array(
                        'max_width' => 500,
                        'max_height' => 375,
                        'jpeg_quality' => 95
                    ),
                    'medium' => array(
                        'max_width' => 160,
                        'max_height' => 160,
                        'jpeg_quality' => 80
                    ),
                    'thumbnail' => array(
                        'max_width' => 100,
                        'max_height' => 100
                    )
                )
            ));
        }
       
    }

Your View file:

<?php

	 /* Load templates */
    echo $this->UploadTemplate->renderForm(array('action' => 'upload')); //Set action for form
    echo $this->UploadTemplate->renderListFiles(array('action_delete' => 'deleteFile')); //Set action for remove files

    /* Load libs js e css jQuery-File-Upload and dependences */
    echo $this->UploadScript->loadLibs();
    echo $this->Html->scriptBlock("
        $(function () {
            $('#fileupload').fileupload({
                    xhrFields   : {withCredentials: true},
                    url         : 'upload' //Set your action
            });
        });    
    ");
?>

##License

The MIT License (MIT)

Copyright (c) 2013 Alexandro Luiz Dias

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cakephp-jqueryfileupload-plugin's People

Contributors

ali3nado avatar julesbern avatar

Stargazers

Thao Phan avatar kousei tokuhara avatar Marlon Almeida avatar Enrique Ibarra avatar Daiki Shirakawa avatar Lukasz Gaszyna avatar  avatar

Watchers

destinydriven avatar  avatar  avatar  avatar

cakephp-jqueryfileupload-plugin's Issues

how to use with security component

Thanks for the code it works great,
Only is there a way to make it work with Security component ? Because it detects blackholing and it is expectable, because the upload form inputs are not being created by $this->Form->input.
I know that I can just add the uploading action to Security component's unlockedActions array, thus, bypassing the blackholing, but in fact, I need high level security and it would be better make it work with security enabled.
Thanks

Error Not Found

Hello, im using your plugin, but i have an issue, when i add files to upload, i can see the miniature correctly in preview, when i want upload the files i see this message:

error Not Found,

Need to change some path ?

For example my action is: /products/view in the function view is where i save the image in app/webroot/images

In my view.ctp i put this
not found

echo $this->UploadScript->loadLibs();
echo $this->Html->scriptBlock("
$(function () {
$('#fileupload').fileupload({
xhrFields : {withCredentials: true},
url : '/admin/products/view/' //Set your action
});
});
");

I'm doing wrong? I hope you can help.

Thanks.

Error SyntaxError: JSON.parse: unexpected character

Hola. Gracias por crear este plugin, soy nueva con json y no logro que funcione el plugin, porque me arroja el siguiente mensaje:

Error SyntaxError: JSON.parse: unexpected character

Cuando miro en firebug, me arroja el siguiente mensaje:

Los datos de la solicitud superan el tamaño límite de Firebug.

Espero que puedas ayudarme.

Gracias.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.