# Cancel upload button

**URL:** <https://www.ruby-forum.com/t/cancel-upload-button/146265>\
**Category:** Rails\
**Created:** [August 19, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265 "2008-08-19T17:11:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 19, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/1 "2008-08-19T17:11:37Z")

</div>

How can I add a cancel button next to the upload button which will stop  
the uploading of multiple files, and how would it be done?

Your reply is appreciated.

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 19, 2008, 9:13pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/2 "2008-08-19T21:13:54Z")

</div>

Hi Joan,

Joan Gu wrote:

There are two components to your question, so I’ll break it up.

> How can I add a cancel button next to the upload button

According to the W3C spec, a form can only have one button within the

 tags that submits the form params. As long as you don't need to carry along the form params on your cancel, the easiest way to do what you're wanting is to use a button\_to outside your form tags and then use CSS to position it, from a visual perspective, along-side the submit button and make it \_appear\_ to the user that side the form has two buttons.

> which will stop the uploading of multiple files, and how would it be done?

If you mean ‘stop the uploading after its been started’, this is a tough  
one  
and I’m not aware of any built-in support in either Ruby or Rails for  
doing  
it. It’s a good question though. I know the capability is built into  
other  
tools, so there must be a way to do it. Maybe someone else will be able  
to  
help with this. It’s definitely interesting. I’ll cipher on it and see  
if  
I can come up with something.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 20, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/3 "2008-08-20T16:42:22Z")

</div>

Hey Bill,

Thanks for reply. Yes, I meant to be stop the uploading after it’s been  
started. I did some search, but comes with no rails solution. Flash is  
an alternative way to do it. Well, last time I use Flash was 7 years  
ago…

Best,  
Joan

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 20, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/4 "2008-08-20T17:28:36Z")

</div>

On Tue, Aug 19, 2008 at 12:13 PM, Bill W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> According to the W3C spec, a form can only have one button within the
> 
> tags that submits the form params.

Uh, sorry, that’s simply not true; multiple SUBMIT buttons are fine.

[http://www.w3.org/TR/html401/interact/forms.html#submit-button](http://www.w3.org/TR/html401/interact/forms.html#submit-button)

17.2.1 Control types

HTML defines the following control types:

buttons  
Authors may create three types of buttons:  
submit buttons: When activated, a submit button submits a form. A  
form may contain  
more than one submit button.

## FWIW,

Hassan S. ------------------------ removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 20, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/5 "2008-08-20T17:42:41Z")

</div>

Hi Hassan,

Hassan S. wrote:

> Uh, sorry, that’s simply not true; multiple SUBMIT buttons are fine.
> 
> [http://www.w3.org/TR/html401/interact/forms.html#submit-button](http://www.w3.org/TR/html401/interact/forms.html#submit-button)

Thanks for the correction. I was thinking forms within forms, which is  
how  
this typically comes up. You are correct of course.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 20, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/6 "2008-08-20T20:01:35Z")

</div>

On 20 Aug 2008, at 16:42, Joan Gu wrote:

> Thanks for reply. Yes, I meant to be stop the uploading after it’s  
> been  
> started. I did some search, but comes with no rails solution. Flash is  
> an alternative way to do it. Well, last time I use Flash was 7 years  
> ago…

There is no solution with normal form submits, and you don’t need to  
know anything about Flash to use a Flash uploader. Go check on  
[swfupload.org](http://swfupload.org) and search the list archives for a post i made about  
SWFUpload and Rails.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![joan2kus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9fc29f/32.png) [@joan2kus](https://www.ruby-forum.com/u/joan2kus)\
**Post date:** [August 20, 2008, 8:18pm UTC](https://www.ruby-forum.com/t/cancel-upload-button/146265/7 "2008-08-20T20:18:35Z")

</div>

Hi Peter,

Peter De Berdt wrote:

> There is no solution with normal form submits, and you  
> don’t need to know anything about Flash to use a Flash  
> uploader. Go check on [swfupload.org](http://swfupload.org) and search the list  
> archives for a post i made about SWFUpload and Rails.

That’s cool. Looks like something I’ll want to add to my toolkit. I  
_would_ like to understand how it’s done though. I haven’t been able to  
come up with the right search string for Google. Nothing gets me to the  
protocol definition type stuff I’m expecting looking for. Can you point  
me?

Thanks,  
Bill
