Skip to content

Can the framework handle multiple files? #2634

Discussion options

You must be logged in to vote

Of course. Here's a fully working application:

use rocket::fs::TempFile;
use rocket::response::content::RawHtml;
use rocket::form::Form;

#[get("/")]
fn upload_page() -> RawHtml<&'static str> {
    RawHtml(r#"
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <title>Upload Example</title>
            </head>
            <body>
                <form method="post" action="/upload" enctype="multipart/form-data">
                    <label for="files">Select files:</label>
                    <input type="file" id="files" name="[]" multiple><br><br>
                    <input type="submit">
                </form>
            </body>
        </html>
    "#)
}

#

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pascal-nil
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2633 on November 01, 2023 00:12.