Examples of async saveUrl datahandlers?

3 posts, 0 answers
  1. Benjamin
    Benjamin avatar
    12 posts
    Member since:
    Nov 2011

    Posted 16 Nov 2011 Link to this post

    We've used many photo up-loaders in the past, uploadify is our current choice.  However, I just bought the Nov30th v1, and wouldn't mind migrating most code to the various widgets KendoUi offers.  I've tried using firebug to figure out our own data handler (simple copy/paste at first and later resizing photos). We currently have uploadify producing nine sizes of photos for us ranging from thumbs to full size.

    Can someone post a sample data handler (processUpload.php) to get us started?
  2. T. Tsonev
    Admin
    T. Tsonev avatar
    2831 posts

    Posted 18 Nov 2011 Link to this post

    Hello Benjamin,

    This is a simple example on how to use the Upload in a PHP application:

    <input name="files" id="files" type="file" />
    <script>
        $(document).ready(function() {
            $("#files").kendoUpload({
                async: {
                    saveUrl: "save.php",
                    removeUrl: "remove.php",
                    autoUpload: true
                }
            });
        });
    </script>

    save.php
    <?php
        $fileParam = "files";
        $uploadRoot = "uploads/";
        $files = $_FILES[$fileParam];
     
        if (isset($files['name']))
        {
            $error = $files['error'];
     
            if ($error == UPLOAD_ERR_OK) {
                $targetPath = $uploadRoot . basename($files["name"]);
                $uploadedFile = $files["tmp_name"];
     
                if (is_uploaded_file($uploadedFile)) {
                    if (!move_uploaded_file($uploadedFile, $targetPath)) {
                        echo "Error moving uploaded file";
                    }
                }
            } else {
                echo "Error code " . $error;
            }
        }

         // Return an empty string to signify success
         echo "";
    ?>

    remove.php

    <?php
        $fileParam = "files";
        $uploadRoot = "uploads/";
        $targetPath = $uploadRoot . basename($_POST["fileNames"]);
     
        unlink($targetPath);
     
        // Return an empty string to signify success
        echo "";
    ?>

    We'll provide an official Code Library article with the official release scheduled for the end of this month.

    I hope this helps.
    Regards,
    Tsvetomir Tsonev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Hernan
    Hernan avatar
    9 posts
    Member since:
    Sep 2012

    Posted 10 Jan 2012 Link to this post

    I'm looking for "official Code Library article" you mentioned but cant fine it? 
Back to Top