Deal MultiPart Form Data in Rust Rocket web frame, easily upload files to server.
All code is in lib.rs. main.rs is a good example to see how it work.
Fist:
rs
use rocket_upload::MultipartDatas;
Then in your handler:
```rs
fn upload(userid: String, contenttype: &ContentType, data: MultipartDatas) -> Html
",userid);
// content
",result,content_type);
// aquire all Form field data
for t in data.texts {
result = format!("{}FieldName:{} --- FieldValue:{}
",result,t.key,t.value);
}
// aquire all files upload
for f in data.files {
result = format!("{}FieldName:{} --- FileName:{} --- StoragePath:{}
",
result,f.name,f.filename,f.path);
f.persist(Path::new("upload"));
}
Html(format!("
The project references the code of Magic Len's https://crates.io/crates/rocket-multipart-form-data