diff --git a/.eslintrc.js b/.eslintrc.js index 88ab3dc9b..0a2e6ea03 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -195,8 +195,9 @@ module.exports = { 'examples/aws-presigned-url/*.js', 'examples/bundled/*.js', 'examples/custom-provider/client/*.js', - 'examples/node-xhr/*.js', 'examples/multiple-instances/*.js', + 'examples/node-xhr/*.js', + 'examples/php-xhr/*.js', 'examples/transloadit-markdown-bin/*.js', 'examples/xhr-bundle/*.js', 'private/dev/*.js', diff --git a/examples/php-xhr/.gitignore b/examples/php-xhr/.gitignore index 4f15b1cce..8fc0d8027 100644 --- a/examples/php-xhr/.gitignore +++ b/examples/php-xhr/.gitignore @@ -1,2 +1 @@ -uppy.min.css -uploads +uploads/ diff --git a/examples/php-xhr/readme.md b/examples/php-xhr/README.md similarity index 76% rename from examples/php-xhr/readme.md rename to examples/php-xhr/README.md index 28968f359..71f74de43 100644 --- a/examples/php-xhr/readme.md +++ b/examples/php-xhr/README.md @@ -6,15 +6,15 @@ This example uses PHP server and `@uppy/xhr-upload` to upload files to the local To run this example, make sure you've correctly installed the **repository root**: -```bash -npm install -npm run build +```sh +corepack yarn install +corepack yarn build ``` That will also install the dependencies for this example. Then, again in the **repository root**, start this example by doing: -```bash -npm run example php-xhr +```sh +corepack yarn workspace @uppy-example/php-xhr start ``` diff --git a/examples/php-xhr/index.html b/examples/php-xhr/index.html index dd6992432..8a98441ec 100644 --- a/examples/php-xhr/index.html +++ b/examples/php-xhr/index.html @@ -4,9 +4,8 @@ PHP + Uppy Example - - + diff --git a/examples/php-xhr/main.js b/examples/php-xhr/main.js index 0fd6963f9..92543820b 100644 --- a/examples/php-xhr/main.js +++ b/examples/php-xhr/main.js @@ -1,7 +1,11 @@ -const Uppy = require('@uppy/core') -const Webcam = require('@uppy/webcam') -const Dashboard = require('@uppy/dashboard') -const XHRUpload = require('@uppy/xhr-upload') +import Uppy from '@uppy/core' +import Webcam from '@uppy/webcam' +import Dashboard from '@uppy/dashboard' +import XHRUpload from '@uppy/xhr-upload' + +import '@uppy/core/dist/style.css' +import '@uppy/dashboard/dist/style.css' +import '@uppy/webcam/dist/style.css' const uppy = new Uppy({ debug: true, diff --git a/examples/php-xhr/package.json b/examples/php-xhr/package.json index 48dd87729..a009ccf3a 100644 --- a/examples/php-xhr/package.json +++ b/examples/php-xhr/package.json @@ -1,24 +1,21 @@ { "name": "@uppy-example/php-xhr", "version": "0.0.0", + "type": "module", "dependencies": { - "@babel/core": "^7.4.4", "@uppy/core": "workspace:*", "@uppy/dashboard": "workspace:*", "@uppy/webcam": "workspace:*", - "@uppy/xhr-upload": "workspace:*", - "babelify": "^10.0.0", - "budo": "^11.3.2", - "cookie-parser": "^1.4.6", - "cors": "^2.8.4", - "formidable": "^1.2.1", - "npm-run-all": "^4.1.3" + "@uppy/xhr-upload": "workspace:*" + }, + "devDependencies": { + "npm-run-all": "^4.1.3", + "vite": "^3.0.0" }, "private": true, "scripts": { - "copy": "cp ../../packages/uppy/dist/uppy.min.css .", - "start": "npm-run-all --serial copy --parallel start:*", - "start:client": "budo main.js:bundle.js -- -t babelify", - "start:server": "mkdir -p uploads && php -S 0.0.0.0:3020" + "start": "npm-run-all --parallel start:server start:client", + "start:client": "vite", + "start:server": "mkdir -p uploads && php -S 0.0.0.0:3020 server.php" } } diff --git a/examples/php-xhr/requirements.txt b/examples/php-xhr/requirements.txt deleted file mode 100644 index ba5902e8e..000000000 --- a/examples/php-xhr/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -flask -werkzeug -flask-cors \ No newline at end of file diff --git a/examples/php-xhr/upload.php b/examples/php-xhr/server.php similarity index 80% rename from examples/php-xhr/upload.php rename to examples/php-xhr/server.php index 08b9a1e0b..761702577 100644 --- a/examples/php-xhr/upload.php +++ b/examples/php-xhr/server.php @@ -18,14 +18,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { exit(0); } -if ($_POST && !empty($_FILES["files"])) { - $target_dir = './uploads/'; - $target_file = $target_dir . basename($_FILES['files']['name'][0]); +if ($_POST && !empty($_FILES["file"])) { + $target_dir = __DIR__ . DIRECTORY_SEPARATOR . 'uploads'; + $target_file = $target_dir . DIRECTORY_SEPARATOR . basename($_FILES['file']['name']); try { - if (move_uploaded_file($_FILES['files']['tmp_name'][0], $target_file)) { + if (move_uploaded_file($_FILES['file']['tmp_name'], $target_file)) { header('Access-Control-Allow-Origin: *'); header('Content-type: application/json'); - $data = ['url' => $target_file, 'message' => 'The file ' . basename($_FILES['files']['name'][0]) . ' has been uploaded.']; + $data = ['url' => $target_file, 'message' => 'The file ' . basename($_FILES['file']['name']) . ' has been uploaded.']; http_response_code(201); echo json_encode($data); } else { diff --git a/yarn.lock b/yarn.lock index 1ee5613f3..a7c877a4f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8162,17 +8162,12 @@ __metadata: version: 0.0.0-use.local resolution: "@uppy-example/php-xhr@workspace:examples/php-xhr" dependencies: - "@babel/core": ^7.4.4 "@uppy/core": "workspace:*" "@uppy/dashboard": "workspace:*" "@uppy/webcam": "workspace:*" "@uppy/xhr-upload": "workspace:*" - babelify: ^10.0.0 - budo: ^11.3.2 - cookie-parser: ^1.4.6 - cors: ^2.8.4 - formidable: ^1.2.1 npm-run-all: ^4.1.3 + vite: ^3.0.0 languageName: unknown linkType: soft