having some trouble uploading a file to a website. after creating a new instance and calling the form on the page i can not seem add the document to the form and then submit.
i get error of not finding the file input that's within the form tags.
when checking what the form brings back with
$form->getValues();
the file upload field is not in the list.
some other things i have tried are
$myInput = $crawler->filterXPath('.//input[@type="file"]');
$myInput->click(); // this returns saying it not clickable
$myInput->sendKeys(C:/location_of_file_i_want_to_upload); // this returns doesn't accept multiple files
If I am not mistaken, you should use $form->getFiles() to check what files were submitted.
$form->getValues() returns values that are not binaries: strings, numbers...
Hi,
having some trouble uploading a file to a website. after creating a new instance and calling the form on the page i can not seem add the document to the form and then submit.
example of the code i am running.
$client = Client::createFirefoxClient();
$crawler = $client->request('GET', 'website_that_has_the_form');
$form = $crawler->selectButton('submit_button')->form();
$form['file'] = 'C:/location_of_file_i_want_to_upload'; $form['Password'] = 'anypass';
$crawler = $client->submit($form);
i get error of not finding the file input that's within the form tags.
when checking what the form brings back with
$form->getValues();
the file upload field is not in the list.
some other things i have tried are
$myInput = $crawler->filterXPath('.//input[@type="file"]'); $myInput->click(); // this returns saying it not clickable $myInput->sendKeys(C:/location_of_file_i_want_to_upload); // this returns doesn't accept multiple files