diff mod_http_upload_external/share_v2.php @ 3226:3b13f19652e2

mod_http_upload_external: Update share.php and share_v2.php to allow cross-domain requests
author Matthew Wild <mwild1@gmail.com>
date Tue, 14 Aug 2018 17:47:44 +0100
parents 5176b8d81ec7
children bada43f3a546
line wrap: on
line diff
--- a/mod_http_upload_external/share_v2.php	Mon Aug 13 03:35:42 2018 +0200
+++ b/mod_http_upload_external/share_v2.php	Tue Aug 14 17:47:44 2018 +0100
@@ -70,6 +70,12 @@
 
 $request_method = $_SERVER['REQUEST_METHOD'];
 
+/* Set CORS headers */
+header('Access-Control-Allow-Methods: GET, PUT, OPTIONS');
+header('Access-Control-Allow-Headers: Content-Type');
+header('Access-Control-Max-Age: 7200');
+header('Access-Control-Allow-Origin: *');
+
 if(array_key_exists('v2', $_GET) === TRUE && $request_method === 'PUT') {
 	error_log(var_export($_SERVER, TRUE));
 	$upload_file_size = $_SERVER['CONTENT_LENGTH'];
@@ -141,6 +147,7 @@
 	} else {
 		header('HTTP/1.0 404 Not Found');
 	}
+} else if($request_method === 'OPTIONS') {
 } else {
 	header('HTTP/1.0 400 Bad Request');
 }