caolan / forms

An easy way to create, parse and validate forms in node.js
MIT License
1.01k stars 167 forks source link

File input? #48

Open kokujin opened 11 years ago

kokujin commented 11 years ago

I know that someone filed an issue about this (https://github.com/caolan/forms/issues/44) Has it been merged? Any news on this? Thanks

ljharb commented 11 years ago

https://github.com/caolan/forms/tree/file_input is the branch… it hasn't been merged. I asked the submitter of #44 to test it for me, and they decided not to do so. Please reopen #44, and please test it yourself, if you'd like to see it merged.

kokujin commented 11 years ago

just tested it, it adds this: "input type="text" name="testfile" id="id_testfile"

. It does not work as expected. How can I reopen this issue?

ljharb commented 11 years ago

Thanks! I'll do some more work on it and update this issue. To reopen, there's a green "reopen" button on the bottom - I'll reopen it now.

kokujin commented 10 years ago

Hi! Any news on this ljharb? Thanks

ljharb commented 10 years ago

I haven't had a chance to work on it yet - I've just taken another look, and it's mostly done - I need to make the example work with multipart form data first.

ljharb commented 10 years ago

I've updated the file_input branch - it creates the input field just fine, and it helped me to figure out that forms needed to handle multipart submissions. However, forms currently only gets "fields" to validate, not "files" - so this is a very complex feature request that will take awhile to get right.

RYFN commented 10 years ago

Any progress on this feature?

danielst-vccp commented 9 years ago

Has anyone found a way to implement this yet?

voxpelli commented 9 years ago

@danielst-vccp: I made a custom image uploader field for a project of mine, if you want to have a reference on how one can approach that: https://github.com/voxpelli/node-one-page/blob/9b2f57bbedf68aa54cbe291d1879741a7da28b7a/lib/utils/forms.js#L22-75 It in turn uses https://github.com/mscdex/connect-busboy to handle the uploaded data and pipes that to Cloudinary.

Not sure if I could wrap that up as a more generic PR or how it relates to the mentioned stale branch, but wanted to point out that it is possible to get fields to work with this module today, even if it is less handy than it could be.

ljharb commented 9 years ago

@danielst-vccp https://github.com/caolan/forms/compare/file_input is my attempt, but it's not working yet, and I haven't had a chance to work on it in awhile.

danielst-vccp commented 9 years ago

@voxpelli @ljharb very helpful, will take a look, thanks chaps.

nervgh commented 7 years ago

@ljharb

https://github.com/caolan/forms/compare/file_input is my attempt, but it's not working yet, and I haven't had a chance to work on it in awhile.

It looks like all tests passed. What did you mean under

it's not working yet

?

ljharb commented 7 years ago

The tests for it aren't sufficient (it's nearly impossible to automate testing of a file input).

It doesn't work, meaning if you load up the examples, and try it - it will not successfully validate the file (if I recall; it's been awhile since I've looked at this)

voxpelli commented 4 years ago

My image field is now possible to use as part of: https://github.com/Sydsvenskan/node-forms-utils#fields