Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples update #1389

Merged
merged 15 commits into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/node-xhr/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ http.createServer(function (req, res) {
if (req.url === '/upload' && req.method.toLowerCase() === 'post') {
// parse a file upload
var form = new formidable.IncomingForm()
form.uploadDir = './uploads'
form.keepExtensions = true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an upload directory, like form.uploadDir = "./uploads"? Otherwise I ran this on mac and couldn’t figure out where the files went. And maybe also preserve the extension. So:

form.uploadDir = "./uploads"
form.keepExtensions = true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add some logging, too, like here: https://stackoverflow.com/a/46973498

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the upload dir and the logging. Also added one more example for PHP

form.parse(req, function (err, fields, files) {
if (err) {
console.log('some error', err)
res.writeHead(200, headers)
res.write(JSON.stringify(err))
return res.end()
}
var file = files['files[]']
console.log('saved file to', file.path)
console.log('original name', file.name)
console.log('type', file.type)
console.log('size', file.size)
res.writeHead(200, headers)
res.write(JSON.stringify({fields, files}))
return res.end()
Expand Down
1 change: 1 addition & 0 deletions examples/php-xhr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uppy.min.css
12 changes: 12 additions & 0 deletions examples/php-xhr/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Python + Uppy Example</title>
<link href="https://transloadit.edgly.net/releases/uppy/v0.30.3/uppy.min.css" rel="stylesheet">
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions examples/php-xhr/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const Uppy = require('@uppy/core')
const Webcam = require('@uppy/webcam')
const Dashboard = require('@uppy/dashboard')
const xhr = require('@uppy/xhr-upload')

const uppy = Uppy({
debug: true,
autoProceed: false
})

uppy.use(Webcam)
uppy.use(Dashboard, {
inline: true,
target: 'body',
plugins: ['Webcam']
})
uppy.use(xhr, {
endpoint: 'http://localhost:3020/upload.php'
})
Loading