Example #1
0
      <h1>Direct <?php 
if ($unsigned) {
    echo "unsigned ";
}
?>
upload from the browser</h1>
      <form>
      <?php 
if ($unsigned) {
    # For the sake of simplicity of the sample site, we generate the preset on the fly. It only needs to be created once, in advance.
    $api = new \Cloudinary\Api();
    $upload_preset = "sample_" . substr(sha1(\Cloudinary\Cloudinary::configGet("api_key") . \Cloudinary\Cloudinary::configGet("api_secret")), 0, 10);
    try {
        $api->uploadPreset($upload_preset);
    } catch (\Cloudinary\Api\NotFound $e) {
        $api->createUploadPreset(array("name" => $upload_preset, "unsigned" => TRUE, "folder" => "preset_folder"));
    }
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_unsigned_image_upload_tag('test', $upload_preset, array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
} else {
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_image_upload_tag('test', array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
}
?>
      <a href="?unsigned=<?php 
echo !$unsigned;
?>
"><?php 
echo $unsigned ? "Use signed upload" : "Use unsigned upload";