Uppy: Upload Locally for Tests

Created on 20 Mar 2018  Â·  2Comments  Â·  Source: transloadit/uppy

Hello everyone.

I'm testing Uppy for the first time. As a young (and desprepared) web developer, I'm having some difficulties with JS (I'm learning from myself) and how to upload an image to a specific folder. I mean, if there's any way that I can do that.

project-example/
-------- images/
-------- node_modules/        /*From npm install uppy --save*/
-------- index.html
-------- package-lock.json 

I've already tried with Tus and XHRUpload, but I'm still getting an "Upload Error".


My index.html file has the following script (got from the examples page)

const uppy = Uppy.Core({
            debug: true,
            autoProceed: false,
            restrictions: {
                maxFileSize: 1000000,
                maxNumberOfFiles: 3,
                minNumberOfFiles: 2,
                allowedFileTypes: ['image/*', 'video/*']
            }
        })
        .use(Uppy.Dashboard, {
            inline: true,
            target: '.UppyDragDrop',
            replaceTargetContent: true,
            note: 'Images and video only, 2–3 files, up to 1 MB',
            metaFields: [
                { id: 'license', name: 'License', placeholder: 'specify license' },
                { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
            ]
        })
        .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, host: 'https://server.uppy.io' })
        .run()

        uppy.on('complete', result => {
            console.log('successful files:', result.successful)
            console.log('failed files:', result.failed)
        })
Question

Most helpful comment

Hi! Sorry for the long response.

You need to set up a local server that will be receiving files, here are some examples
in PHP: https://gist.github.com/taterbase/2688850 and https://www.w3schools.com/php/php_file_upload.asp. And here’s a tutorial in Node: https://medium.com/@bmshamsnahid/nodejs-file-upload-using-multer-3a904516f6d2.

Our XHRUpload docs then explain a little about how to receive a file from Uppy with PHP: https://uppy.io/docs/xhrupload/#Uploading-to-a-PHP-Server.

All 2 comments

Hi! Sorry for the long response.

You need to set up a local server that will be receiving files, here are some examples
in PHP: https://gist.github.com/taterbase/2688850 and https://www.w3schools.com/php/php_file_upload.asp. And here’s a tutorial in Node: https://medium.com/@bmshamsnahid/nodejs-file-upload-using-multer-3a904516f6d2.

Our XHRUpload docs then explain a little about how to receive a file from Uppy with PHP: https://uppy.io/docs/xhrupload/#Uploading-to-a-PHP-Server.

Thanks! :smiley:
Sorry for the late reply!

Was this page helpful?
0 / 5 - 0 ratings