This is a migrated thread and some comments may be shown as answers.

Examples of async saveUrl datahandlers?

2 Answers 684 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 16 Nov 2011, 07:45 PM
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 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 18 Nov 2011, 02:11 PM
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!
0
Hernan
Top achievements
Rank 1
answered on 11 Jan 2012, 12:59 AM
I'm looking for "official Code Library article" you mentioned but cant fine it? 
Tags
Upload
Asked by
Benjamin
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Hernan
Top achievements
Rank 1
Share this question
or