forked from cloudinary/cloudinary_php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
115 lines (100 loc) · 3.89 KB
/
Copy pathupload.php
File metadata and controls
115 lines (100 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
require 'main.php';
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>PhotoAlbum - Upload page</title>
<link href="style.css" media="all" rel="stylesheet" />
<link rel="shortcut icon"
href="<?php echo cloudinary_url("http://cloudinary.com/favicon.png",
array("type" => "fetch")); ?>" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="lib/jquery.ui.widget.js"></script>
<script src="lib/jquery.iframe-transport.js"></script>
<script src="lib/jquery.fileupload.js"></script>
<script src="lib/jquery.cloudinary.js"></script>
<?php echo cloudinary_js_config(); ?>
</head>
<body>
<div id="logo">
<!-- This will render the image fetched from a remote HTTP URL using Cloudinary -->
<?php echo fetch_image_tag("http://cloudinary.com/images/logo.png") ?>
</div>
<div id="posterframe">
<!-- This will render the fetched Facebook profile picture using Cloudinary according to the
requested transformations -->
<?php echo facebook_profile_image_tag("officialchucknorrispage", array(
"format" => "png",
"transformation" => array(
array("height" => 95, "width" => 95, "crop" => "thumb", "gravity" => "face",
"effect" => "sepia", "radius" => 20
), array("angle" => 10)
)));
?>
</div>
<!-- A standard form for sending the image data to your server -->
<div id='backend_upload'>
<h1>Upload through your server</h1>
<form action="upload_backend.php" method="post" enctype="multipart/form-data">
<input id="fileupload" type="file" name="files[]" multiple accept="image/gif, image/jpeg, image/png">
<input type="submit" value="Upload">
</form>
</div>
<!-- A form for direct uploading using a jQuery plug-in.
The cl_image_upload_tag PHP function generates the required HTML and JavaScript to
allow uploading directly frm the browser to your Cloudinary account -->
<div id='direct_upload'>
<h1>Direct upload from the browser</h1>
<form>
<?php
# 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)));
?>
</form>
<!-- status box -->
<div class="status">
<h2>Status</h2>
<span class="status_value">Idle</span>
</div>
<div class="uploaded_info_holder">
</div>
</div>
<a href="list.php" class="back_link">Back to list...</a>
<script>
function prettydump(obj) {
ret = ""
$.each(obj, function(key, value) {
ret += "<tr><td>" + key + "</td><td>" + value + "</td></tr>";
});
return ret;
}
$(function() {
$('.cloudinary-fileupload')
.fileupload({
dropZone: '#direct_upload',
start: function () {
$('.status_value').text('Starting direct upload...');
},
progress: function () {
$('.status_value').text('Uploading...');
},
})
.on('cloudinarydone', function (e, data) {
$('.status_value').text('Idle');
$.post('upload_complete.php', data.result);
var info = $('<div class="uploaded_info"/>');
$(info).append($('<div class="data"/>').append(prettydump(data.result)));
$(info).append($('<div class="image"/>').append(
$.cloudinary.image(data.result.public_id, {
format: data.result.format, width: 150, height: 150, crop: "fill"
})
));
$('.uploaded_info_holder').append(info);
});
});
</script>
</body>
</html>