To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.
Progress-bar is supported in FF3.6+, Chrome6+, Safari4+
\ No newline at end of file
diff --git a/server/php.php b/server/php.php
index 6f03cfe9a..5bc9ecc35 100644
--- a/server/php.php
+++ b/server/php.php
@@ -27,24 +27,22 @@
*/
class qqUploadedFileXhr {
/**
- * Save the file to the specified path
- * @return boolean TRUE on success
- */
- function save($path) {
+ * Save the file to the specified path
+ * @return boolean TRUE on success
+ */
+ function save($path) {
$input = fopen("php://input", "r");
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
-
- if ($realSize != $this->getSize()){
- return false;
- }
-
- $target = fopen($path, "w");
+
+ if ($realSize != $this->getSize()) return false;
+
+ $target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
-
+
return true;
}
function getName() {
@@ -52,11 +50,11 @@ function getName() {
}
function getSize() {
if (isset($_SERVER["CONTENT_LENGTH"])){
- return (int)$_SERVER["CONTENT_LENGTH"];
+ return (int)$_SERVER["CONTENT_LENGTH"];
} else {
throw new Exception('Getting content length is not supported.');
- }
- }
+ }
+ }
}
/**
@@ -86,49 +84,48 @@ class qqFileUploader {
private $sizeLimit = 10485760;
private $file;
- function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){
+ function __construct(array $allowedExtensions = array(), $sizeLimit = 10485760){
$allowedExtensions = array_map("strtolower", $allowedExtensions);
-
- $this->allowedExtensions = $allowedExtensions;
+
+ $this->allowedExtensions = $allowedExtensions;
$this->sizeLimit = $sizeLimit;
-
- $this->checkServerSettings();
+
+ $this->checkServerSettings();
if (isset($_GET['qqfile'])) {
$this->file = new qqUploadedFileXhr();
} elseif (isset($_FILES['qqfile'])) {
$this->file = new qqUploadedFileForm();
} else {
- $this->file = false;
+ $this->file = false;
}
}
-
- public function getName(){
- if ($this->file)
- return $this->file->getName();
- }
-
- private function checkServerSettings(){
+
+ public function getName(){
+ if ($this->file) return $this->file->getName();
+ }
+
+ private function checkServerSettings(){
$postSize = $this->toBytes(ini_get('post_max_size'));
- $uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
-
+ $uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
+
if ($postSize < $this->sizeLimit || $uploadSize < $this->sizeLimit){
- $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M';
- die("{'error':'increase post_max_size and upload_max_filesize to $size'}");
- }
+ $size = max(1, $this->sizeLimit / 1024 / 1024) . 'M';
+ die("{'error':'increase post_max_size and upload_max_filesize to $size'}");
+ }
}
-
+
private function toBytes($str){
$val = trim($str);
$last = strtolower($str[strlen($str)-1]);
switch($last) {
case 'g': $val *= 1024;
case 'm': $val *= 1024;
- case 'k': $val *= 1024;
+ case 'k': $val *= 1024;
}
return $val;
}
-
+
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
@@ -136,44 +133,44 @@ function handleUpload($uploadDirectory, $replaceOldFile = FALSE){
if (!is_writable($uploadDirectory)){
return array('error' => "Server error. Upload directory isn't writable.");
}
-
+
if (!$this->file){
return array('error' => 'No files were uploaded.');
}
-
+
$size = $this->file->getSize();
-
+
if ($size == 0) {
return array('error' => 'File is empty');
}
-
+
if ($size > $this->sizeLimit) {
return array('error' => 'File is too large');
}
-
+
$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];
//$filename = md5(uniqid());
- $ext = @$pathinfo['extension']; // hide notices if extension is empty
+ $ext = @$pathinfo['extension']; // hide notices if extension is empty
if($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)){
$these = implode(', ', $this->allowedExtensions);
return array('error' => 'File has an invalid extension, it should be one of '. $these . '.');
}
-
+
if(!$replaceOldFile){
/// don't overwrite previous files that were uploaded
while (file_exists($uploadDirectory . $filename . '.' . $ext)) {
$filename .= rand(10, 99);
}
}
-
+
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)){
return array('success'=>true);
} else {
return array('error'=> 'Could not save uploaded file.' .
'The upload was cancelled, or server error encountered');
}
-
- }
+
+ }
}
diff --git a/tests/action-acceptance.php b/tests/action-acceptance.php
index fc9583f21..ff2a8c0b3 100644
--- a/tests/action-acceptance.php
+++ b/tests/action-acceptance.php
@@ -7,15 +7,15 @@
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
- // xhr request
- $headers = apache_request_headers();
- $fileSize = (int)$headers['Content-Length'];
+
+ // xhr request
+ $headers = apache_request_headers();
+ $fileSize = (int)$headers['Content-Length'];
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
$fileSize = $_FILES['qqfile']['size'];
} else {
- die ('{error: "server-error file not passed"}');
+ die ('{error: "server-error file not passed"}');
}
if ($fileName == '4text.txt'){
@@ -36,11 +36,11 @@
if (count($_GET)){
array_merge($_GET, array('fileName'=>$fileName));
-
+
$response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName));
-
- // to pass data through iframe you will need to encode all html tags
- echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
+
+ // to pass data through iframe you will need to encode all html tags
+ echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
} else {
- die ('{error: "server-error query params not passed"}');
+ die ('{error: "server-error query params not passed"}');
}
diff --git a/tests/action-handler-queue-test.php b/tests/action-handler-queue-test.php
index ff13576dd..bcc4d627e 100644
--- a/tests/action-handler-queue-test.php
+++ b/tests/action-handler-queue-test.php
@@ -6,26 +6,26 @@
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
- // xhr request
- $headers = apache_request_headers();
- if ((int)$headers['Content-Length'] == 0){
- die ('{error: "content length is zero"}');
- }
+
+ // xhr request
+ $headers = apache_request_headers();
+ if ((int)$headers['Content-Length'] == 0){
+ die ('{error: "content length is zero"}');
+ }
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
-
- // form request
- if ($_FILES['qqfile']['size'] == 0){
- die ('{error: "file size is zero"}');
- }
+
+ // form request
+ if ($_FILES['qqfile']['size'] == 0){
+ die ('{error: "file size is zero"}');
+ }
} else {
- die ('{error: "file not passed"}');
+ die ('{error: "file not passed"}');
}
if (count($_GET)){
$_GET['success'] = true;
- echo json_encode(array_merge($_GET));
+ echo json_encode(array_merge($_GET));
} else {
- die ('{error: "query params not passed"}');
+ die ('{error: "query params not passed"}');
}
diff --git a/tests/action-handler-test.php b/tests/action-handler-test.php
index 24466b122..e27c297cd 100644
--- a/tests/action-handler-test.php
+++ b/tests/action-handler-test.php
@@ -6,26 +6,26 @@
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];
-
- // xhr request
- $headers = apache_request_headers();
- if ((int)$headers['Content-Length'] == 0){
- die ('{error: "content length is zero"}');
- }
+
+ // xhr request
+ $headers = apache_request_headers();
+ if ((int)$headers['Content-Length'] == 0){
+ die ('{error: "content length is zero"}');
+ }
} elseif (isset($_FILES['qqfile'])){
$fileName = basename($_FILES['qqfile']['name']);
-
- // form request
- if ($_FILES['qqfile']['size'] == 0){
- die ('{error: "file size is zero"}');
- }
+
+ // form request
+ if ($_FILES['qqfile']['size'] == 0){
+ die ('{error: "file size is zero"}');
+ }
} else {
- die ('{error: "file not passed"}');
+ die ('{error: "file not passed"}');
}
if (count($_GET)){
- //return query params
- echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
+ //return query params
+ echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
} else {
- die ('{error: "query params not passed"}');
+ die ('{error: "query params not passed"}');
}
diff --git a/tests/browser-bugs/safari-bug1.htm b/tests/browser-bugs/safari-bug1.htm
index ef0eb0b1b..3b3ed4922 100644
--- a/tests/browser-bugs/safari-bug1.htm
+++ b/tests/browser-bugs/safari-bug1.htm
@@ -2,7 +2,7 @@
-
+
Drag multiple files into input field. (Win7)
Result: One file is selected multiple times. Expected: Multiple files are selected.
diff --git a/tests/browser-bugs/safari-bug2.htm b/tests/browser-bugs/safari-bug2.htm
index 57f7bc013..12492cf2f 100644
--- a/tests/browser-bugs/safari-bug2.htm
+++ b/tests/browser-bugs/safari-bug2.htm
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/tests/iframe-content-tests/text-html-large.php b/tests/iframe-content-tests/text-html-large.php
index ac9682be9..4bc50999a 100644
--- a/tests/iframe-content-tests/text-html-large.php
+++ b/tests/iframe-content-tests/text-html-large.php
@@ -1,6 +1,6 @@
"&a, to download means to receive data to a local system from a remote system, or to initiate such a data transfer. Examples of a remote system from which a download might be performed include a webserver, FTP server, email server, or other similar systems. A download can mean either any file that is offered for downloading or that has been downloaded, or the process of receiving such a file.The inverse operation, uploading, can refer to the sending of data from a local system to a remote system such as a server or another client with the intent that the remote system should store a copy of the data being transferred, or the initiation of such a process. The words first came into popular usage among computer users with the increased popularity of Bulletin Board Systems (BBSs), facilitated by the widespread distribution and implementation of dial-up access the in the 1970s",
- 'sub' => array('arr'=>array(10,20,30), 'boo'=>false)
- );
- echo htmlspecialchars(json_encode($data), ENT_NOQUOTES);
+ header('Content-type: text/html');
+ $data = array(
+ 'example' => "&a, to download means to receive data to a local system from a remote system, or to initiate such a data transfer. Examples of a remote system from which a download might be performed include a webserver, FTP server, email server, or other similar systems. A download can mean either any file that is offered for downloading or that has been downloaded, or the process of receiving such a file.The inverse operation, uploading, can refer to the sending of data from a local system to a remote system such as a server or another client with the intent that the remote system should store a copy of the data being transferred, or the initiation of such a process. The words first came into popular usage among computer users with the increased popularity of Bulletin Board Systems (BBSs), facilitated by the widespread distribution and implementation of dial-up access the in the 1970s",
+ 'sub' => array('arr'=>array(10,20,30), 'boo'=>false)
+ );
+ echo htmlspecialchars(json_encode($data), ENT_NOQUOTES);
diff --git a/tests/qunit/package.json b/tests/qunit/package.json
index b6044c887..fd65dfbab 100644
--- a/tests/qunit/package.json
+++ b/tests/qunit/package.json
@@ -1,21 +1,21 @@
{
- "name": "qunit",
- "author": {
- "name": "John Resig",
- "email": "jeresig@gmail.com",
- "url": "http://ejohn.org/"
- },
- "maintainer": {
- "name": "Jörn Zaefferer",
- "email": "joern.zaefferer@googlemail.com",
- "url": "http://bassistance.de/"
- },
- "url": "http://docs.jquery.com/QUnit",
- "license": {
- "name": "MIT",
- "url": "http://www.opensource.org/licenses/mit-license.php"
- },
- "description": "An easy-to-use JavaScript Unit Testing framework.",
- "keywords": [ "testing", "unit", "jquery" ],
- "lib": "qunit"
+ "name": "qunit",
+ "author": {
+ "name": "John Resig",
+ "email": "jeresig@gmail.com",
+ "url": "http://ejohn.org/"
+ },
+ "maintainer": {
+ "name": "Jörn Zaefferer",
+ "email": "joern.zaefferer@googlemail.com",
+ "url": "http://bassistance.de/"
+ },
+ "url": "http://docs.jquery.com/QUnit",
+ "license": {
+ "name": "MIT",
+ "url": "http://www.opensource.org/licenses/mit-license.php"
+ },
+ "description": "An easy-to-use JavaScript Unit Testing framework.",
+ "keywords": [ "testing", "unit", "jquery" ],
+ "lib": "qunit"
}
diff --git a/tests/qunit/test/index.html b/tests/qunit/test/index.html
index 8a9f86500..51fc0b25d 100644
--- a/tests/qunit/test/index.html
+++ b/tests/qunit/test/index.html
@@ -1,17 +1,17 @@
- QUnit Test Suite
-
-
-
-
+ QUnit Test Suite
+
+
+
+
-
QUnit Test Suite
-
-
-
-
+
QUnit Test Suite
+
+
+
+
diff --git a/tests/qunit/test/same.js b/tests/qunit/test/same.js
index 8f1b5630f..7e43c9e7a 100644
--- a/tests/qunit/test/same.js
+++ b/tests/qunit/test/same.js
@@ -451,7 +451,7 @@ test("Complex Objects.", function() {
function fn2() {
return "fn2";
}
-
+
// Try to invert the order of some properties to make sure it is covered.
// It can failed when properties are compared between unsorted arrays.
equals(QUnit.equiv(
diff --git a/tests/separate-file-list.htm b/tests/separate-file-list.htm
index 424142942..8fc6421b9 100644
--- a/tests/separate-file-list.htm
+++ b/tests/separate-file-list.htm
@@ -2,23 +2,23 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+ });
+ }
+ window.onload = createUploader;
+
\ No newline at end of file
diff --git a/tests/test-acceptance.htm b/tests/test-acceptance.htm
index 985c20b03..dbbb083b5 100644
--- a/tests/test-acceptance.htm
+++ b/tests/test-acceptance.htm
@@ -1,27 +1,27 @@
-
+
-
+
-
-
+
+
+
-
+
File uploader tests
@@ -95,12 +95,12 @@
In FF,Chrome, select all files using drag-and-drop, only 1 error should appear.
-
+
- Open this page via https connection, and make sure that loading bar is not acting strange after all tests are run.
- Back button test fails in Opera.
-
-
-
Please select a file for each input below (in order)
+
File uploader tests
+
+
+
+
+
+ Open this page via https connection, and make sure that loading bar is not acting strange after all tests are run.
+ Back button test fails in Opera.
+
+
+
Please select a file for each input below (in order)