Hi everybody, I have a problem using WWW::Mechanize::Firefox to upload a file to a site with a form using an input type file, like this :
<form enctype="multipart/form-data" action="uploader.php" method="POST +" id="formular"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="image0" type="file" id="image0"/ +><br /> <input type="submit" value="Upload File" />
The content of uploader.php is the following :
<?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['image0']['name']); if(move_uploaded_file($_FILES['image0']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['image0']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file,". basename( $_FILES[ +'image0']['name'])." please try again!"; } ?>
And the code I use for uploading the file is the following :
#!/usr/bin/perl use strict; use warnings; use WWW::Mechanize::Firefox; my $bot = WWW::Mechanize::Firefox->new( autoclose => 0,activate =>1); $bot->get('http://127.0.0.1/file/index.html'); $bot->form_id('formular'); $bot->field('image0','IMAGE.JPG'); $bot->submit;
There is no error at execution, and the form is submited but without nothing in image0.
The version of WWW::Mechanize::Firefox I use is 0.66 my perl version is : v5.10.0 built for MSWin32-x86-multi-thread
Thanks
In reply to WWW::Mechanize::Firefox and input type file by nicko.martin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |