public function getUploadHtml($redirect = false)
 {
     $options = array();
     if (!$redirect) {
         $redirect = $this->app->getUrl() . $this->app->getRequestUri();
     }
     $options['success_action_redirect'] = $redirect;
     $options['starts-with'] = $this->key . '/';
     $upload = new S3BrowserUpload();
     $form = $upload->generate_upload_parameters($this->bucket, '1 hour', $options);
     return $form;
 }
Example #2
0
    }
    if (empty($filemime)) {
        print json_encode(array('error' => 'must provide the mime'));
        return;
    }
    if (strpos($filename, '..') !== false) {
        print json_encode(array('error' => 'not relative paths'));
        return;
    }
    $expires = '+15 minutes';
    //token will be valid only for 15 minutes
    $path_file = "{$bucket_path}/{$filename}";
    $mime = $filemime;
    //help the browsers to interpret the content
    //get the params for s3 to upload directly
    $s3_uploader = new S3BrowserUpload();
    $params = $s3_uploader->generate_upload_parameters($bucket, $expires, array('acl' => AmazonS3::ACL_PUBLIC, 'key' => $path_file, 'Content-Type' => $mime));
    print json_encode(array('error' => '', 'url' => "http://{$params['form']['action']}", 'params' => $params['inputs']));
    return;
}
//params for index.php
$url_iframe = 'http://danguer-blog.s3.amazonaws.com/upload-html5/index.html';
//setup where is stored your s3 files
$url_iframe_host = parse_url($url_iframe);
$url_iframe_host = $url_iframe_host['host'];
?>

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">