Hi,

You can find an example of file upload testing here: 
https://metacpan.org/pod/Test::Mojo#post_ok

I haven't tested what follows, but in your case (using "file" as the name 
of the file input field and "/uploadsave" as the url to post) that should 
be:

my $upload = {file => {file => '/path/to/the/file/to/upload'}};
$t->post_ok('/uploadsave' => form => $upload)->status_is(200);

(the first "file" corresponds to the name of the input field, and that will 
be the name of the parameter at your controller. The second "file" tells 
the user agent that it should upload the file that follows);

Hope it helps.
BR,

El miércoles, 3 de enero de 2018, 0:09:49 (UTC-3), [email protected] 
escribió:
>
> Hello all,
>
> How do I ask the test object to upload files?
> Here's the source code for dragging files to the drop zone:
>
>  <form action="/uploadsave" method="post" class="dropzone" id="dropzoneform" 
> enctype="multipart/form-data">  </form>
>  <script type="text/javascript">      Dropzone.options.dropzoneform = {       
>                                                         init: function() {    
>                   uploadMultiple: true,                   
> this.on("queuecomplete", function() {                                         
>                   console.log("queue completed.");                            
>     window.location.reload(true);                    });                      
>                       this.on("success", function(file, response) {           
>                 console.log(file.name + " files successfully uploaded.");     
>                   });                     this.on("error", function(file, 
> errorMessage) {                         console.log(errorMessage);            
>           });             }       };  </script>
>
> And the source code for selecting a file to submit:
>
>    <form action="/uploadsave" id="uploadform" method="post" 
> enctype="multipart/form-data" style="display:block">     <label 
> for="idupload">Upload A New File: </label>     <input type="file" name="file" 
> id="idupload" style="display:inline"  >   </form>   <script>      
> document.getElementById("idupload").onchange = function() {         
> document.getElementById("uploadform").submit();      }   </script>
>
> Thanks!
>
> Ni
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to