Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I let users upload files by copy/paste?

I'm trying to create a web app based on ExtJS, and I'm working on the file-upload area of the app.

I want users to be able to upload files by copying and pasting them - not just copying and pasting the contents of the file, but the file itself. For example, in Windows, you can choose "Copy" or "Cut" from the Edit menu while a file is selected, then choose "Paste" later and copy or move the file - I'd like users to be able to upload files to my app in the Paste step, by just choosing Paste in their browser.

I've already tried HTML5's drag-and-drop API, but we don't want to use that - we want users to be able to copy/cut and paste files to upload their files (as long as they're smaller than 20 megabytes). If the user copies the path to their file and pastes that directly to the page, telling us where to find the file, that could also work.

Can anyone suggest a way to do this?

like image 501
Saransh Sharma Avatar asked Dec 11 '11 22:12

Saransh Sharma


People also ask

How do I allow others to upload to my OneDrive?

Choose the folder you want to upload files to and select 'request files' Describe what files you are requesting. Send a link to people or enter their emails. You'll receive a notification email whenever someone uploads files to your file request folder.

Why can't I use file upload in Google Forms?

Turn off Data Loss Prevention (or the file upload option will be greyed out) If your administrator has turned on data loss prevention this can also lead to the file upload option being greyed out as well.


1 Answers

The thing is, that you're not able to access the clients filesystem with javascript. There is this new Filesystem API, but this just allows you to create a virtual sandboxed filesystem. I had the same problem, thought about it a while and came up with the following ideas.

  1. Flash

    Writing a Flash bridge which access the filesystem and let the javascript communicate with it via swliveconnect

    Problem: Flash doesn't have filesystem access either.

  2. Java applet

    Same thing as Flash and again with LiveConnect

    In my opinion this could work, but I didn't try it out, because my goal was to get filesystem access on a chromebook. And chromeOS doesn't support Java (at least without some hacking)

  3. ActiveX

    I also found some solutions with this. I gave up at the applet part so I didn't try this out either.

As Jared Farrish said, when you copy a file the os just saves the path to the file in the clipboard. Then if you receive the paste event on your webapp just get the string out of the clipboard and forward it to your file bridge.

like image 117
Dominic Avatar answered Oct 28 '22 09:10

Dominic