Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading files to forms doesn't work #320

Open
eliocamp opened this issue Jun 7, 2021 · 1 comment
Open

Uploading files to forms doesn't work #320

eliocamp opened this issue Jun 7, 2021 · 1 comment
Labels
feature a feature request or enhancement form 🧾

Comments

@eliocamp
Copy link

eliocamp commented Jun 7, 2021

I'm trying to fill out a form that includes file upload. I used to be able to do something like this

form <- rvest::html_form_set(form, list(file = httr::upload_file(file))
session <- rvest::session_submit(session, form)

(with the equivalent deprecated functions)

However, now the server is returning an error saying that the file was not uploaded. Eventually I worked around the issue by manually setting the file after submission_build(). This works:

submit_form <- rvest:::submission_build(submit_form, NULL)

submit_form$values$file <- httr::upload_file(file)

resp <- suppressMessages(rvest:::submission_submit(submit_form, session$config, handle = session$handle))
session <- rvest:::session_set_response(session, resp)

I'd love to give a reprex but I don't know of any public service that could be used for testing this out.

@deanm0000
Copy link

I was having the same issue and your workaround worked for me.

@hadley hadley added feature a feature request or enhancement form 🧾 labels Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement form 🧾
Projects
None yet
Development

No branches or pull requests

3 participants