0

I'm using the simplehttpwithupload.py script, which I have linked to below, to host a simple http server where people can upload files to me. Is there a way to modify the source code so that multiple files can be selected for upload at once? Such that when the select file dialog box comes up, users can ctrl/shift click and select several files which will then be uploaded.

https://www.dropbox.com/s/wshzyseignnz78x/simplehttpwithupload.py

Thanks

3
  • 1
    That's not a Python question. Have a look at the html5 file api, or you can use flash. Then you can worry about how to handle the data you send. Commented Feb 8, 2013 at 21:18
  • Why is this not a python question? I'm talking about modifying the PYTHON source code. Commented Feb 8, 2013 at 21:22
  • 1
    @chew: because you're talking about modify browser behavior. python can do absolutely nothing about that. even if python generated the page with the file upload form, it cannot do ANYTHING to change how a browser behaves with a file input field. Commented Feb 8, 2013 at 21:23

1 Answer 1

1

Is there a way to modify the source code so that multiple files can be selected for upload at once? Such that when the select file dialog box comes up, users can ctrl/shift click and select several files

I'm pretty sure there's not a simple way. Things may have improved, but when I looked into this a year or two ago, the only solution for exactly what you're looking for is Flash based. The problem is that the file selection dialog is on the client side and multiple file selection is not directly supported in the browser.

There is a JavaScript based solution for downloading multiple files, but it doesn't exactly match what you asked for. See Upload multiple files with a single file element for the explanation, and Multiple file uploader: Mootools version for a later, prettier version.

The main idea is:

you can only store file upload information in a file upload element (), you’ll always need to have one element per file to be uploaded.

it’s actually a relatively simple matter to conceal a file element once a file has been chosen, and add a new (empty) one in its place.

To apply the JavaScript solution to simplehttpwithupload.py, you'll have to rewrite the list_directory function.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the answer. I did not realize that dialog box is client side.
@chew socks, is there anything else I can do to make this answer more acceptable to you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.