Skip to content

Commit edb4036

Browse files
committed
Use POST instead of GET to translate requests with param _method="DELETE" to the delete method.
Add the missing "PUT" support to the XDomainRequest plugin.
1 parent 04786d2 commit edb4036

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

gae/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# jQuery File Upload Plugin GAE Example 1.1.2
3+
# jQuery File Upload Plugin GAE Example 1.1.3
44
# https://github.com/blueimp/jQuery-File-Upload
55
#
66
# Copyright 2010, Sebastian Tschan
@@ -108,11 +108,11 @@ def head(self):
108108
pass
109109

110110
def get(self):
111-
if (self.request.get('_method') == 'DELETE'):
112-
return self.delete()
113111
self.redirect(WEBSITE)
114112

115113
def post(self):
114+
if (self.request.get('_method') == 'DELETE'):
115+
return self.delete()
116116
s = json.dumps(self.handle_upload(), separators=(',',':'))
117117
redirect = self.request.get('redirect')
118118
if redirect:

jquery.xdr-transport.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery XDomainRequest Transport Plugin 1.0
2+
* jQuery XDomainRequest Transport Plugin 1.0.1
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -37,7 +37,11 @@
3737
if (s.type === 'DELETE') {
3838
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
3939
'_method=DELETE';
40-
s.type = 'GET';
40+
s.type = 'POST';
41+
} else if (s.type === 'PUT') {
42+
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
43+
'_method=PUT';
44+
s.type = 'POST';
4145
}
4246
xdr.open(s.type, s.url);
4347
xdr.onload = function () {

php/index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* jQuery File Upload Plugin PHP Example 5.4.1
3+
* jQuery File Upload Plugin PHP Example 5.4.2
44
* https://github.com/blueimp/jQuery-File-Upload
55
*
66
* Copyright 2010, Sebastian Tschan
@@ -243,9 +243,6 @@ private function handle_file_upload($uploaded_file, $name, $size, $type, $error)
243243
}
244244

245245
public function get() {
246-
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
247-
return $this->delete();
248-
}
249246
$file_name = isset($_REQUEST['file']) ?
250247
basename(stripslashes($_REQUEST['file'])) : null;
251248
if ($file_name) {
@@ -258,6 +255,9 @@ public function get() {
258255
}
259256

260257
public function post() {
258+
if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
259+
return $this->delete();
260+
}
261261
$upload = isset($_FILES[$this->options['param_name']]) ?
262262
$_FILES[$this->options['param_name']] : null;
263263
$info = array();

0 commit comments

Comments
 (0)