aboutsummaryrefslogtreecommitdiffstats
path: root/addon/js_upload/file-uploader/tests/action-acceptance.php
blob: fc9583f213deafeb6180152872f8ac7b97ae8b86 (plain) (blame)
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
<?php

usleep(100000);

$fileName;
$fileSize;

if (isset($_GET['qqfile'])){
    $fileName = $_GET['qqfile'];
    
	// 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"}');
}

if ($fileName == '4text.txt'){
    die ('jsgkdfgu4eyij');
}

if ($fileSize == 0){
    die ('{error: "server-error file size is zero"}');
}

if ($fileSize < 10){
    die ('{error: "server-error file size is smaller than 10 bytes"}');
}

if ($fileSize > 9 * 1024){
    die ('{error: "server-error file size is bigger than 9kB"}');
}

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);	
} else {
	die ('{error: "server-error  query params not passed"}');
}