Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update examples.

  • Loading branch information...
commit a705acb22881fc626ebb6e0b23b18fe104542274 1 parent 62aadd2
@jayarjo jayarjo authored
View
31 examples/custom.html
@@ -5,44 +5,17 @@
<title>Plupload - Custom example</title>
-<style type="text/css">
- body {
- font-family:Verdana, Geneva, sans-serif;
- font-size:13px;
- color:#333;
- background:url(bg.jpg);
- }
-</style>
-
<!-- production -->
<script type="text/javascript" src="../js/plupload.full.min.js"></script>
<!-- -->
<!-- debug
-<script type="text/javascript" src="../src/moxie/src/javascript/core/mOxie.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/Utils.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/Exceptions.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/I18N.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/EventTarget.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/Runtime.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/Transporter.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/FileAPI.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/Image.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/extra/ImageInfo.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/core/XMLHttpRequest.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/html5.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/html4.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/flash.js"></script>
-<script type="text/javascript" src="../src/moxie/src/javascript/silverlight.js"></script>
-
+<script type="text/javascript" src="../js/moxie.js"></script>
<script type="text/javascript" src="../src/plupload.js"></script>
-->
-
-<!-- <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> -->
-
</head>
-<body>
+<body style="font:13px Verdana;background:url(bg.jpg);color:#333">
<h1>Custom example</h1>
View
11 examples/jquery/all_runtimes.html
@@ -5,14 +5,6 @@
<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="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
@@ -20,9 +12,8 @@
<script type="text/javascript" src="../../js/plupload.full.min.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>
+<body style="font:13px Verdana;background:url(../bg.jpg);color:#333">
<form method="post" action="dump.php">
<h1>Queue widget example</h1>
View
37 examples/jquery/jquery_ui_widget.html
@@ -5,48 +5,24 @@
<title>Plupload - jQuery UI Widget</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="//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 src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
<!-- production -->
<script type="text/javascript" src="../../js/plupload.full.min.js"></script>
-<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
+<script type="text/javascript" src="../../src/jquery.ui.plupload/jquery.ui.plupload.js"></script>
<!-- debug
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/mOxie.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Utils.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Exceptions.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/I18N.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/EventTarget.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Runtime.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Transporter.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/FileAPI.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Image.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/extra/ImageInfo.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/XMLHttpRequest.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/html5.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/html4.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/flash.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/silverlight.js"></script>
-
+<script type="text/javascript" src="../../js/moxie.js"></script>
<script type="text/javascript" src="../../src/plupload.js"></script>
<script type="text/javascript" src="../../src/jquery.ui.plupload/jquery.ui.plupload.js"></script>
-->
</head>
-<body>
+<body style="font:13px Verdana;background:url(../bg.jpg);color:#333">
<h1>jQuery UI Widget</h1>
@@ -68,7 +44,7 @@
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,
+ rename : true,
multiple_queues : true,
// Resize images on clientside if we can
@@ -105,8 +81,7 @@
list: true,
thumbs: true // Show thumbs
},
- default_view: 'thumbs',
- remember_view: true // requires jquery cookie plugin
+ default_view: 'thumbs'
});
// Client side form validation
View
36 examples/jquery/queue_widget.html
@@ -5,47 +5,23 @@
<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 src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<!-- production -->
<script type="text/javascript" src="../../js/plupload.full.min.js"></script>
-<script type="text/javascript" src="../../js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
+<script type="text/javascript" src="../../src/jquery.plupload.queue/jquery.plupload.queue.js"></script>
<!-- debug
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/mOxie.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Utils.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Exceptions.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/I18N.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/EventTarget.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Runtime.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Transporter.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/FileAPI.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/Image.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/extra/ImageInfo.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/core/XMLHttpRequest.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/html5.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/html4.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/flash.js"></script>
-<script type="text/javascript" src="../../src/moxie/src/javascript/silverlight.js"></script>
-
+<script type="text/javascript" src="../../js/moxie.js"></script>
<script type="text/javascript" src="../../src/plupload.js"></script>
-<script type="text/javascript" src="../../src/jquery.plupload.queue/jquery.plupload.queue.js"></script>
+<script type="text/javascript" src="../../src/jquery.ui.plupload/jquery.ui.plupload.js"></script>
-->
-
</head>
-<body>
+<body style="font:13px Verdana;background:url(../bg.jpg);color:#333">
<form method="post" action="dump.php">
<div id="uploader">
@@ -64,7 +40,7 @@
url : '../upload.php',
max_file_size : '10mb',
chunk_size : '1mb',
- unique_names : true,
+ rename : true,
dragdrop: true,
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
View
16 examples/jquery/s3.php
@@ -76,15 +76,6 @@ function hash_hmac($algo, $data, $key, $raw_output = false)
<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>
@@ -94,10 +85,9 @@ function hash_hmac($algo, $data, $key, $raw_output = false)
<script type="text/javascript" src="../../js/plupload.full.min.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>
+<body style="font:13px Verdana;background:url(../bg.jpg);color:#333">
<h1>Plupload to Amazon S3 Example</h1>
@@ -141,10 +131,10 @@ function hash_hmac($algo, $data, $key, $raw_output = false)
],
// Flash settings
- flash_swf_url : '../../js/plupload.flash.swf',
+ flash_swf_url : '../../js/Moxie.swf',
// Silverlight settings
- silverlight_xap_url : '../../js/plupload.silverlight.xap'
+ silverlight_xap_url : '../../js/Moxie.xap'
});
});
</script>
View
143 examples/upload.php
@@ -2,13 +2,19 @@
/**
* upload.php
*
- * Copyright 2009, Moxiecode Systems AB
+ * Copyright 2013, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
+// 5 minutes execution time
+@set_time_limit(5 * 60);
+
+// Uncomment this one to fake upload time
+// usleep(5000);
+
// 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");
@@ -19,109 +25,76 @@
// Settings
$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
//$targetDir = 'uploads';
-
$cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds
-// 5 minutes execution time
-@set_time_limit(5 * 60);
-
-// Uncomment this one to fake upload time
-// usleep(5000);
+// Create target dir
+if (!file_exists($targetDir)) {
+ @mkdir($targetDir);
+}
-// Get parameters
-$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
-$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
+$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
-// 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);
+$chunking = is_numeric($_REQUEST["offset"]) && is_numeric($_REQUEST["total"]);
- $count = 1;
- while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b))
- $count++;
- $fileName = $fileName_a . '_' . $count . $fileName_b;
-}
+// Remove old temp files
+if ($cleanupTargetDir) {
+ if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
+ }
-$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
+ while (($file = readdir($dir)) !== false) {
+ $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
-// Create target dir
-if (!file_exists($targetDir))
- @mkdir($targetDir);
+ // If temp file is current file proceed to the next
+ if ($tmpfilePath == "{$filePath}.part") {
+ continue;
+ }
-// Remove old temp files
-if ($cleanupTargetDir) {
- if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
- while (($file = readdir($dir)) !== false) {
- $tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
-
- // Remove temp file if it is older than the max age and is not the current file
- if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge) && ($tmpfilePath != "{$filePath}.part")) {
- @unlink($tmpfilePath);
- }
+ // Remove temp file if it is older than the max age and is not the current file
+ if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
+ @unlink($tmpfilePath);
}
- closedir($dir);
- } else {
- die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
}
+ closedir($dir);
}
-// 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("{$filePath}.part", $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
+
+// Open temp file
+if (!$out = @fopen("{$filePath}.part", $chunking ? "cb" : "wb")) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
+}
+
+if (!empty($_FILES)) {
+ if ($_FILES['file']['error'] || !is_uploaded_file($_FILES['file']['tmp_name'])) {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
-} else {
- // Open temp file
- $out = @fopen("{$filePath}.part", $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"}');
+ }
+
+ // Read binary input stream and append it to temp file
+ if (!$in = @fopen($_FILES['file']['tmp_name'], "rb")) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+ }
+} else {
+ if (!$in = @fopen("php://input", "rb")) {
+ die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
+ }
}
+if ($chunking) {
+ fseek($out, $_REQUEST["offset"]); // write at a specific offset
+}
+
+while ($buff = fread($in, 4096)) {
+ fwrite($out, $buff);
+}
+
+@fclose($out);
+@fclose($in);
+
// Check if file has been uploaded
-if (!$chunks || $chunk == $chunks - 1) {
+if (!$chunking || filesize("{$filePath}.part") >= $_REQUEST["total"]) {
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
}
Please sign in to comment.
Something went wrong with that request. Please try again.