Skip to content

Commit 7db43f3

Browse files
committed
+ iframe/json section
1 parent b9ff25b commit 7db43f3

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ If you need a CORS, then edit the `crossdomain.xml` and put it in the root of re
5050

5151
<a name="FileAPI.getFiles"></a>
5252
### getFiles(input`:HTMLInputElement|Event|$.Event`)`:Array`
53-
Get files from `input` element or `event` object, also support `jQuery`.
53+
Retrieve file list from `input` element or `event` object, also support `jQuery`.
5454

5555
* input — `HTMLInputElement`, `change` and `drop` event, `jQuery` collection or `jQuery.Event`
5656

5757
```js
5858
var el = document.getElement('my-input');
5959
FileAPI.event.on(el, function (evt/**Event*/){
60-
// Get files from input
60+
// Retrieve file list
6161
var files = FileAPI.getFiles(el);
6262

6363
// or event
@@ -1123,12 +1123,42 @@ Submit Query
11231123
<a name="server"></a>
11241124
## Server settings
11251125
1126+
<a name="server.iframe"></a>
1127+
### IFrame/JSONP
1128+
Example ctrl.php.
1129+
1130+
```php
1131+
<?php
1132+
include './FileAPI.class.php';
1133+
1134+
if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
1135+
// Retrieve File List
1136+
$files = FileAPI::getFiles();
1137+
1138+
// ... your logic
1139+
1140+
// JSONP callback name
1141+
$jsonp = isset($_REQUEST['callback']) ? trim($_REQUEST['callback']) : null;
1142+
1143+
// Server response: "HTTP/1.1 200 OK"
1144+
FileAPI::makeResponse(array(
1145+
'status' => FileAPI::OK
1146+
, 'statusText' => 'OK'
1147+
, 'body' => array('count' => sizeof($files)
1148+
), $jsonp);
1149+
exit;
1150+
}
1151+
?>
1152+
```
1153+
1154+
---
1155+
11261156
<a name="server.CORS"></a>
11271157
### CORS
11281158
Enable CORS.
11291159
11301160
```php
1131-
<?
1161+
<?php
11321162
// Permitted types of request
11331163
header('Access-Control-Allow-Methods: POST, OPTIONS');
11341164
@@ -1148,6 +1178,7 @@ Enable CORS.
11481178
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
11491179
// ...
11501180
}
1181+
?>
11511182
```
11521183
11531184
---
@@ -1177,6 +1208,7 @@ All the other codes - fatal error, user's involvement is recommend.
11771208
11781209
---
11791210
1211+
11801212
<a name="buttons.examples"></a>
11811213
## Buttons examples
11821214

README.ru.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,42 @@ Submit Query
11061106
<a name="server"></a>
11071107
## Server settings
11081108
1109+
<a name="server.iframe"></a>
1110+
### IFrame/JSONP
1111+
Пример ctrl.php.
1112+
1113+
```php
1114+
<?php
1115+
include './FileAPI.class.php';
1116+
1117+
if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
1118+
// Получим список файлов
1119+
$files = FileAPI::getFiles();
1120+
1121+
// ... ваша логика
1122+
1123+
// JSONP callback name
1124+
$jsonp = isset($_REQUEST['callback']) ? trim($_REQUEST['callback']) : null;
1125+
1126+
// Ответ сервера: "HTTP/1.1 200 OK"
1127+
FileAPI::makeResponse(array(
1128+
'status' => FileAPI::OK
1129+
, 'statusText' => 'OK'
1130+
, 'body' => array('count' => sizeof($files)
1131+
), $jsonp);
1132+
exit;
1133+
}
1134+
?>
1135+
```
1136+
1137+
---
1138+
11091139
<a name="server.CORS"></a>
11101140
### CORS
11111141
Включение CORS.
11121142
11131143
```php
1114-
<?
1144+
<?php
11151145
// Permitted types of request
11161146
header('Access-Control-Allow-Methods: POST, OPTIONS');
11171147

server/ctrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
24-
$files = FileAPI::getFiles(); // get files from request
24+
$files = FileAPI::getFiles(); // Retrieve File List
2525
$images = array();
2626

2727

statics/docs.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)