first global commit
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,94 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
|
||||
<title>Plupload - Queue widget example</title>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(bg.jpg);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/plupload.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.gears.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.silverlight.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.browserplus.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="../js/plupload.html5.js"></script>
|
||||
|
||||
<!-- <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form id="submit-form" method="post" action="dump.php">
|
||||
<h1>Custom example</h1>
|
||||
|
||||
<p>Shows you how to use the core plupload API.</p>
|
||||
|
||||
<div>
|
||||
<div id="filelist">No runtime found.</div>
|
||||
<br />
|
||||
<a id="pickfiles" href="javascript:;">[Select files]</a>
|
||||
<a id="uploadfiles" href="javascript:;">[Upload files]</a>
|
||||
</div>
|
||||
|
||||
<input type="submit" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Custom example logic
|
||||
function $(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
|
||||
var uploader = new plupload.Uploader({
|
||||
runtimes : 'gears,html5,flash,silverlight,browserplus',
|
||||
browse_button : 'pickfiles',
|
||||
max_file_size : '10mb',
|
||||
url : 'upload.php',
|
||||
resize : {width : 320, height : 240, quality : 90},
|
||||
flash_swf_url : '../js/plupload.flash.swf',
|
||||
silverlight_xap_url : '../js/plupload.silverlight.xap',
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
]
|
||||
});
|
||||
|
||||
uploader.bind('Init', function(up, params) {
|
||||
$('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
|
||||
});
|
||||
|
||||
uploader.bind('FilesAdded', function(up, files) {
|
||||
for (var i in files) {
|
||||
$('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
|
||||
}
|
||||
});
|
||||
|
||||
uploader.bind('UploadFile', function(up, file) {
|
||||
$('submit-form').innerHTML += '<input type="hidden" name="file-' + file.id + '" value="' + file.name + '" />';
|
||||
});
|
||||
|
||||
uploader.bind('UploadProgress', function(up, file) {
|
||||
$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
|
||||
});
|
||||
|
||||
$('uploadfiles').onclick = function() {
|
||||
uploader.start();
|
||||
return false;
|
||||
};
|
||||
|
||||
uploader.init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="stylesheet" href="css/plupload.css" type="text/css" media="screen" />
|
||||
<title>Plupload - Form dump</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(bg.jpg);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Post dump</h1>
|
||||
|
||||
<p>Shows the form items posted.</p>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<?php $count = 0; foreach ($_POST as $name => $value) { ?>
|
||||
<tr class="<?php echo $count % 2 == 0 ? 'alt' : ''; ?>">
|
||||
<td><?php echo $name ?></td>
|
||||
<td><?php echo nl2br(htmlentities(stripslashes($value))) ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,196 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<link rel="stylesheet" href="../../js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" />
|
||||
<title>Plupload - Events example</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(../bg.jpg);
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../../js/plupload.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="../../js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="post" action="dump.php">
|
||||
<h1>Events example</h1>
|
||||
|
||||
<p>Shows how to bind and use all available events.</p>
|
||||
|
||||
<h3>Log messages</h3>
|
||||
<textarea id="log" style="width: 100%; height: 150px; font-size: 11px" spellcheck="false" wrap="off"></textarea>
|
||||
|
||||
<h3>Queue widget</h3>
|
||||
<div id="uploader" style="width: 450px; height: 330px;">You browser doesn't support upload.</div>
|
||||
<a id="clear" href="#">Clear queue</a>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
function log() {
|
||||
var str = "";
|
||||
|
||||
plupload.each(arguments, function(arg) {
|
||||
var row = "";
|
||||
|
||||
if (typeof(arg) != "string") {
|
||||
plupload.each(arg, function(value, key) {
|
||||
// Convert items in File objects to human readable form
|
||||
if (arg instanceof plupload.File) {
|
||||
// Convert status to human readable
|
||||
switch (value) {
|
||||
case plupload.QUEUED:
|
||||
value = 'QUEUED';
|
||||
break;
|
||||
|
||||
case plupload.UPLOADING:
|
||||
value = 'UPLOADING';
|
||||
break;
|
||||
|
||||
case plupload.FAILED:
|
||||
value = 'FAILED';
|
||||
break;
|
||||
|
||||
case plupload.DONE:
|
||||
value = 'DONE';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(value) != "function") {
|
||||
row += (row ? ', ': '') + key + '=' + value;
|
||||
}
|
||||
});
|
||||
|
||||
str += row + " ";
|
||||
} else {
|
||||
str += arg + " ";
|
||||
}
|
||||
});
|
||||
|
||||
$('#log').val($('#log').val() + str + "\r\n");
|
||||
}
|
||||
|
||||
$("#uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes: 'html5,gears,browserplus,silverlight,flash,html4',
|
||||
url: '../upload.php',
|
||||
max_file_size: '10mb',
|
||||
chunk_size: '1mb',
|
||||
unique_names: true,
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize: {width: 320, height: 240, quality: 90},
|
||||
|
||||
// Specify what files to browse for
|
||||
filters: [
|
||||
{title: "Image files", extensions: "jpg,gif,png"},
|
||||
{title: "Zip files", extensions: "zip"}
|
||||
],
|
||||
|
||||
// Flash/Silverlight paths
|
||||
flash_swf_url: '../../js/plupload.flash.swf',
|
||||
silverlight_xap_url: '../../js/plupload.silverlight.xap',
|
||||
|
||||
// PreInit events, bound before any internal events
|
||||
preinit: {
|
||||
Init: function(up, info) {
|
||||
log('[Init]', 'Info:', info, 'Features:', up.features);
|
||||
},
|
||||
|
||||
UploadFile: function(up, file) {
|
||||
log('[UploadFile]', file);
|
||||
|
||||
// You can override settings before the file is uploaded
|
||||
// up.settings.url = 'upload.php?id=' + file.id;
|
||||
// up.settings.multipart_params = {param1: 'value1', param2: 'value2'};
|
||||
}
|
||||
},
|
||||
|
||||
// Post init events, bound after the internal events
|
||||
init: {
|
||||
Refresh: function(up) {
|
||||
// Called when upload shim is moved
|
||||
log('[Refresh]');
|
||||
},
|
||||
|
||||
StateChanged: function(up) {
|
||||
// Called when the state of the queue is changed
|
||||
log('[StateChanged]', up.state == plupload.STARTED ? "STARTED": "STOPPED");
|
||||
},
|
||||
|
||||
QueueChanged: function(up) {
|
||||
// Called when the files in queue are changed by adding/removing files
|
||||
log('[QueueChanged]');
|
||||
},
|
||||
|
||||
UploadProgress: function(up, file) {
|
||||
// Called while a file is being uploaded
|
||||
log('[UploadProgress]', 'File:', file, "Total:", up.total);
|
||||
},
|
||||
|
||||
FilesAdded: function(up, files) {
|
||||
// Callced when files are added to queue
|
||||
log('[FilesAdded]');
|
||||
|
||||
plupload.each(files, function(file) {
|
||||
log(' File:', file);
|
||||
});
|
||||
},
|
||||
|
||||
FilesRemoved: function(up, files) {
|
||||
// Called when files where removed from queue
|
||||
log('[FilesRemoved]');
|
||||
|
||||
plupload.each(files, function(file) {
|
||||
log(' File:', file);
|
||||
});
|
||||
},
|
||||
|
||||
FileUploaded: function(up, file, info) {
|
||||
// Called when a file has finished uploading
|
||||
log('[FileUploaded] File:', file, "Info:", info);
|
||||
},
|
||||
|
||||
ChunkUploaded: function(up, file, info) {
|
||||
// Called when a file chunk has finished uploading
|
||||
log('[ChunkUploaded] File:', file, "Info:", info);
|
||||
},
|
||||
|
||||
Error: function(up, args) {
|
||||
// Called when a error has occured
|
||||
|
||||
// Handle file specific error and general error
|
||||
if (args.file) {
|
||||
log('[error]', args, "File:", args.file);
|
||||
} else {
|
||||
log('[error]', args);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#log').val('');
|
||||
$('#clear').click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#uploader").pluploadQueue().splice();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<title>Plupload - Queue widget example</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(../bg.jpg);
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../../js/plupload.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
|
||||
|
||||
<!--<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>jQuery UI Widget</h1>
|
||||
|
||||
<p>You can see this example with different themes on the <a href="http://plupload.com/example_jquery_ui.php">www.plupload.com</a> website.</p>
|
||||
|
||||
<form method="post" action="dump.php">
|
||||
<div id="uploader">
|
||||
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
// Convert divs to queue widgets when the DOM is ready
|
||||
$(function() {
|
||||
$("#uploader").plupload({
|
||||
// General settings
|
||||
runtimes : 'flash,html5,browserplus,silverlight,gears,html4',
|
||||
url : '../upload.php',
|
||||
max_file_size : '1000mb',
|
||||
max_file_count: 20, // user can add no more then 20 files at a time
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
multiple_queues : true,
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90},
|
||||
|
||||
// Rename files by clicking on their titles
|
||||
rename: true,
|
||||
|
||||
// Sort files
|
||||
sortable: true,
|
||||
|
||||
// Specify what files to browse for
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip,avi"}
|
||||
],
|
||||
|
||||
// Flash settings
|
||||
flash_swf_url : '../../js/plupload.flash.swf',
|
||||
|
||||
// Silverlight settings
|
||||
silverlight_xap_url : '../../js/plupload.silverlight.xap'
|
||||
});
|
||||
|
||||
// Client side form validation
|
||||
$('form').submit(function(e) {
|
||||
var uploader = $('#uploader').plupload('getUploader');
|
||||
|
||||
// Validate number of uploaded files
|
||||
if (uploader.total.uploaded == 0) {
|
||||
// Files in queue upload them first
|
||||
if (uploader.files.length > 0) {
|
||||
// When all files are uploaded submit form
|
||||
uploader.bind('UploadProgress', function() {
|
||||
if (uploader.total.uploaded == uploader.files.length)
|
||||
$('form').submit();
|
||||
});
|
||||
|
||||
uploader.start();
|
||||
} else
|
||||
alert('You must at least upload one file.');
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,174 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<title>Plupload - Queue widget example</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(../bg.jpg);
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" />
|
||||
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../../js/plupload.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="../../js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
|
||||
<!-- <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> -->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="post" action="dump.php">
|
||||
<h1>Queue widget example</h1>
|
||||
|
||||
<p>Shows the jQuery Plupload Queue widget and under different runtimes.</p>
|
||||
|
||||
<div style="float: left; margin-right: 20px">
|
||||
<h3>Flash runtime</h3>
|
||||
<div id="flash_uploader" style="width: 450px; height: 330px;">You browser doesn't have Flash installed.</div>
|
||||
|
||||
<h3>Gears runtime</h3>
|
||||
<div id="gears_uploader" style="width: 450px; height: 330px;">You browser doesn't have Gears installed.</div>
|
||||
</div>
|
||||
|
||||
<div style="float: left; margin-right: 20px">
|
||||
<h3>Silverlight runtime</h3>
|
||||
<div id="silverlight_uploader" style="width: 450px; height: 330px;">You browser doesn't have Silverlight installed.</div>
|
||||
|
||||
<h3>HTML 5 runtime</h3>
|
||||
<div id="html5_uploader" style="width: 450px; height: 330px;">You browser doesn't support native upload. Try Firefox 3 or Safari 4.</div>
|
||||
</div>
|
||||
|
||||
<div style="float: left; margin-right: 20px">
|
||||
<h3>BrowserPlus runtime</h3>
|
||||
<div id="browserplus_uploader" style="width: 450px; height: 330px;">You browser doesn't have BrowserPlus installed.</div>
|
||||
|
||||
<h3>HTML 4 runtime</h3>
|
||||
<div id="html4_uploader" style="width: 450px; height: 330px;">You browser doesn't have HTML 4 support.</div>
|
||||
</div>
|
||||
|
||||
<br style="clear: both" />
|
||||
|
||||
<input type="submit" value="Send" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// Setup flash version
|
||||
$("#flash_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'flash',
|
||||
url : '../upload.php',
|
||||
max_file_size : '10mb',
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
],
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90},
|
||||
|
||||
// Flash settings
|
||||
flash_swf_url : '../../js/plupload.flash.swf'
|
||||
});
|
||||
|
||||
// Setup gears version
|
||||
$("#gears_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'gears',
|
||||
url : 'upload.php',
|
||||
max_file_size : '10mb',
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
],
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90}
|
||||
});
|
||||
|
||||
// Setup silverlight version
|
||||
$("#silverlight_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'silverlight',
|
||||
url : 'upload.php',
|
||||
max_file_size : '10mb',
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
],
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90},
|
||||
|
||||
// Silverlight settings
|
||||
silverlight_xap_url : '../../js/plupload.silverlight.xap'
|
||||
});
|
||||
|
||||
// Setup html5 version
|
||||
$("#html5_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'html5',
|
||||
url : 'upload.php',
|
||||
max_file_size : '10mb',
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
],
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90}
|
||||
});
|
||||
|
||||
// Setup browserplus version
|
||||
$("#browserplus_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'browserplus',
|
||||
url : 'upload.php',
|
||||
max_file_size : '10mb',
|
||||
chunk_size : '1mb',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
],
|
||||
|
||||
// Resize images on clientside if we can
|
||||
resize : {width : 320, height : 240, quality : 90}
|
||||
});
|
||||
|
||||
// Setup html4 version
|
||||
$("#html4_uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes : 'html4',
|
||||
url : 'upload.php',
|
||||
unique_names : true,
|
||||
filters : [
|
||||
{title : "Image files", extensions : "jpg,gif,png"},
|
||||
{title : "Zip files", extensions : "zip"}
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/*
|
||||
In order to upload files to S3 using Flash runtime, one should start by placing crossdomain.xml into the bucket.
|
||||
crossdomain.xml can be as simple as this:
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
|
||||
<cross-domain-policy>
|
||||
<allow-access-from domain="*" secure="false" />
|
||||
</cross-domain-policy>
|
||||
|
||||
In our tests SilverLight didn't require anything special and worked with this configuration just fine. It may fail back
|
||||
to the same crossdomain.xml as last resort.
|
||||
|
||||
!!!Important!!! Plupload UI Widget here, is used only for demo purposes and is not required for uploading to S3.
|
||||
*/
|
||||
|
||||
// important variables that will be used throughout this example
|
||||
$bucket = 'BUCKET';
|
||||
|
||||
// these can be found on your Account page, under Security Credentials > Access Keys
|
||||
$accessKeyId = 'ACCESS_KEY_ID';
|
||||
$secret = 'SECRET_ACCESS_KEY';
|
||||
|
||||
|
||||
// hash_hmac — Generate a keyed hash value using the HMAC method
|
||||
// (PHP 5 >= 5.1.2, PECL hash >= 1.1)
|
||||
if (!function_exists('hash_hmac')) :
|
||||
// based on: http://www.php.net/manual/en/function.sha1.php#39492
|
||||
function hash_hmac($algo, $data, $key, $raw_output = false)
|
||||
{
|
||||
$blocksize = 64;
|
||||
if (strlen($key) > $blocksize)
|
||||
$key = pack('H*', $algo($key));
|
||||
|
||||
$key = str_pad($key, $blocksize, chr(0x00));
|
||||
$ipad = str_repeat(chr(0x36), $blocksize);
|
||||
$opad = str_repeat(chr(0x5c), $blocksize);
|
||||
$hmac = pack('H*', $algo(($key^$opad) . pack('H*', $algo(($key^$ipad) . $data))));
|
||||
|
||||
return $raw_output ? $hmac : bin2hex($hmac);
|
||||
}
|
||||
endif;
|
||||
|
||||
// prepare policy
|
||||
$policy = base64_encode(json_encode(array(
|
||||
// ISO 8601 - date('c'); generates uncompatible date, so better do it manually
|
||||
'expiration' => date('Y-m-d\TH:i:s.000\Z', strtotime('+1 day')),
|
||||
'conditions' => array(
|
||||
array('bucket' => $bucket),
|
||||
array('acl' => 'public-read'),
|
||||
array('starts-with', '$key', ''),
|
||||
// for demo purposes we are accepting only images
|
||||
array('starts-with', '$Content-Type', 'image/'),
|
||||
// "Some versions of the Adobe Flash Player do not properly handle HTTP responses that have an empty body.
|
||||
// To configure POST to return a response that does not have an empty body, set success_action_status to 201.
|
||||
// When set, Amazon S3 returns an XML document with a 201 status code."
|
||||
// http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTFlash.html
|
||||
array('success_action_status' => '201'),
|
||||
// Plupload internally adds name field, so we need to mention it here
|
||||
array('starts-with', '$name', ''),
|
||||
// One more field to take into account: Filename - gets silently sent by FileReference.upload() in Flash
|
||||
// http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTFlash.html
|
||||
array('starts-with', '$Filename', ''),
|
||||
)
|
||||
)));
|
||||
|
||||
// sign policy
|
||||
$signature = base64_encode(hash_hmac('sha1', $policy, $secret, true));
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<title>Plupload to Amazon S3 Example</title>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family:Verdana, Geneva, sans-serif;
|
||||
font-size:13px;
|
||||
color:#333;
|
||||
background:url(../bg.jpg);
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
||||
<script src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
|
||||
|
||||
<!-- Load plupload and all it's runtimes and finally the UI widget -->
|
||||
<link rel="stylesheet" href="../../js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../../js/plupload.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
|
||||
<!--<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>-->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Plupload to Amazon S3 Example</h1>
|
||||
|
||||
<div id="uploader">
|
||||
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Convert divs to queue widgets when the DOM is ready
|
||||
$(function() {
|
||||
$("#uploader").plupload({
|
||||
runtimes : 'flash,silverlight',
|
||||
url : 'http://<?php echo $bucket; ?>.s3.amazonaws.com/',
|
||||
max_file_size : '10mb',
|
||||
|
||||
multipart: true,
|
||||
multipart_params: {
|
||||
'key': '${filename}', // use filename as a key
|
||||
'Filename': '${filename}', // adding this to keep consistency across the runtimes
|
||||
'acl': 'public-read',
|
||||
'Content-Type': 'image/jpeg',
|
||||
'success_action_status': '201',
|
||||
'AWSAccessKeyId' : '<?php echo $accessKeyId; ?>',
|
||||
'policy': '<?php echo $policy; ?>',
|
||||
'signature': '<?php echo $signature; ?>'
|
||||
},
|
||||
|
||||
// !!!Important!!!
|
||||
// this is not recommended with S3, since it will force Flash runtime into the mode, with no progress indication
|
||||
//resize : {width : 800, height : 600, quality : 60}, // Resize images on clientside, if possible
|
||||
|
||||
// optional, but better be specified directly
|
||||
file_data_name: 'file',
|
||||
|
||||
// re-use widget (not related to S3, but to Plupload UI Widget)
|
||||
multiple_queues: true,
|
||||
|
||||
// Specify what files to browse for
|
||||
filters : [
|
||||
{title : "JPEG files", extensions : "jpg"}
|
||||
],
|
||||
|
||||
// Flash settings
|
||||
flash_swf_url : '../../js/plupload.flash.swf',
|
||||
|
||||
// Silverlight settings
|
||||
silverlight_xap_url : '../../js/plupload.silverlight.xap'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* upload.php
|
||||
*
|
||||
* Copyright 2009, Moxiecode Systems AB
|
||||
* Released under GPL License.
|
||||
*
|
||||
* License: http://www.plupload.com/license
|
||||
* Contributing: http://www.plupload.com/contributing
|
||||
*/
|
||||
|
||||
// HTTP headers for no cache etc
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
// Settings
|
||||
//$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
||||
$targetDir = 'uploads/';
|
||||
|
||||
//$cleanupTargetDir = false; // Remove old files
|
||||
//$maxFileAge = 60 * 60; // Temp file age in seconds
|
||||
|
||||
// 5 minutes execution time
|
||||
@set_time_limit(5 * 60);
|
||||
|
||||
// Uncomment this one to fake upload time
|
||||
// usleep(5000);
|
||||
|
||||
// Get parameters
|
||||
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
|
||||
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
|
||||
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
||||
|
||||
// Clean the fileName for security reasons
|
||||
$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
||||
|
||||
// Make sure the fileName is unique but only if chunking is disabled
|
||||
if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
$ext = strrpos($fileName, '.');
|
||||
$fileName_a = substr($fileName, 0, $ext);
|
||||
$fileName_b = substr($fileName, $ext);
|
||||
|
||||
$count = 1;
|
||||
while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b))
|
||||
$count++;
|
||||
|
||||
$fileName = $fileName_a . '_' . $count . $fileName_b;
|
||||
}
|
||||
|
||||
// Create target dir
|
||||
if (!file_exists($targetDir))
|
||||
@mkdir($targetDir);
|
||||
|
||||
// Remove old temp files
|
||||
/* this doesn't really work by now
|
||||
|
||||
if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
|
||||
while (($file = readdir($dir)) !== false) {
|
||||
$filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
// Remove temp files if they are older than the max age
|
||||
if (preg_match('/\\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
|
||||
@unlink($filePath);
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
|
||||
*/
|
||||
|
||||
// Look for the content type header
|
||||
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
|
||||
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
|
||||
|
||||
if (isset($_SERVER["CONTENT_TYPE"]))
|
||||
$contentType = $_SERVER["CONTENT_TYPE"];
|
||||
|
||||
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
|
||||
if (strpos($contentType, "multipart") !== false) {
|
||||
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
|
||||
// Open temp file
|
||||
$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
|
||||
if ($out) {
|
||||
// Read binary input stream and append it to temp file
|
||||
$in = fopen($_FILES['file']['tmp_name'], "rb");
|
||||
|
||||
if ($in) {
|
||||
while ($buff = fread($in, 4096))
|
||||
fwrite($out, $buff);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
|
||||
fclose($in);
|
||||
fclose($out);
|
||||
@unlink($_FILES['file']['tmp_name']);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
|
||||
} else {
|
||||
// Open temp file
|
||||
$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
|
||||
if ($out) {
|
||||
// Read binary input stream and append it to temp file
|
||||
$in = fopen("php://input", "rb");
|
||||
|
||||
if ($in) {
|
||||
while ($buff = fread($in, 4096))
|
||||
fwrite($out, $buff);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
|
||||
|
||||
fclose($in);
|
||||
fclose($out);
|
||||
} else
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
|
||||
}
|
||||
|
||||
// Return JSON-RPC response
|
||||
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user