Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Copy File Field Value to Dynamic File Field Value (http://www.velocityreviews.com/forums/t933506-copy-file-field-value-to-dynamic-file-field-value.html)

VUNETdotUS 11-07-2007 02:33 PM

Copy File Field Value to Dynamic File Field Value
 
Firefox showed me a security error when I was copying a value of file
field object into new DOM created input file field. Can I do something
about it?
Thanks.


s0lnic 11-07-2007 02:55 PM

Re: Copy File Field Value to Dynamic File Field Value
 
VUNETdotUS wrote:

> Firefox showed me a security error when I was copying a value of file
> field object into new DOM created input file field. Can I do something
> about it?


Nope, it's a security issue, you're not able to manipulate file fields.

--
# Regards || piotr[.]solnica[at]gmail[.]com || jid : s0lnic@jabster.pl #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #

VUNETdotUS 11-07-2007 05:12 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 9:55 am, s0lnic <l...@my.sig> wrote:
> VUNETdotUS wrote:
> > Firefox showed me a security error when I was copying a value of file
> > field object into new DOM created input file field. Can I do something
> > about it?

>
> Nope, it's a security issue, you're not able to manipulate file fields.
>
> --
> # Regards || piotr[.]solnica[at]gmail[.]com || jid : s0l...@jabster.pl #
> # s0lnic ||http://blog.solnic.in5.pl || icq : 385935391 #


can I copy input as a DOM object to another form (thus keeping its
value)?


s0lnic 11-07-2007 06:30 PM

Re: Copy File Field Value to Dynamic File Field Value
 
VUNETdotUS wrote:

> can I copy input as a DOM object to another form (thus keeping its
> value)?


Well, you can do something like:

var fileField = document.getElementById('file_field_id');
var clonedFileField = fileField.cloneNode(true);
document.getElementById('some_form').appendChild(c lonedFileField);

This should work fine on gecko-based browsers, but I'm not sure about Opera
and IEs.

--
# Regards || piotr[.]solnica[at]gmail[.]com || jid : s0lnic@jabster.pl #
# s0lnic || http://blog.solnic.in5.pl || icq : 385935391 #

VUNETdotUS 11-07-2007 06:41 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 12:51 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> VUNETdotUS said the following on 11/7/2007 9:33 AM:
>
> > Firefox showed me a security error when I was copying a value of file
> > field object into new DOM created input file field. Can I do something
> > about it?

>
> Yes. Stop trying to copy the value of a file input.


Sounds inspiring.

>
> --
> Randy
> Chance Favors The Prepared Mind
> comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
> Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/




VUNETdotUS 11-07-2007 07:19 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 2:03 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> s0lnic said the following on 11/7/2007 1:30 PM:
>
> > VUNETdotUS wrote:

>
> >> can I copy input as a DOM object to another form (thus keeping its
> >> value)?

>
> > Well, you can do something like:

>
> > var fileField = document.getElementById('file_field_id');
> > var clonedFileField = fileField.cloneNode(true);
> > document.getElementById('some_form').appendChild(c lonedFileField);

>
> > This should work fine on gecko-based browsers, but I'm not sure about Opera
> > and IEs.

>
> Don't let the IE bashing crowd know that IE gets something right with
> regards to security and Gecko-based/Opera browsers get it wrong. Namely,
> that you shouldn't, under any circumstance, be able to set the value of
> a file input.
>
> --
> Randy
> Chance Favors The Prepared Mind
> comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
> Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


I do not really set the value. User sets the value, then I run the
script to take that value, create a new form in DOM, append new input
file field with user-defined value to this new form and submit.
I need it to upload the files without refreshing the page. So, my new
form is submitting to iframe and user keeps on working with current
visible form.
Any suggestions, perhaps?
Thanks


VUNETdotUS 11-07-2007 08:00 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 2:24 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> VUNETdotUS said the following on 11/7/2007 2:19 PM:
>
>
>
> > On Nov 7, 2:03 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> >> s0lnic said the following on 11/7/2007 1:30 PM:

>
> >>> VUNETdotUS wrote:
> >>>> can I copy input as a DOM object to another form (thus keeping its
> >>>> value)?
> >>> Well, you can do something like:
> >>> var fileField = document.getElementById('file_field_id');
> >>> var clonedFileField = fileField.cloneNode(true);
> >>> document.getElementById('some_form').appendChild(c lonedFileField);
> >>> This should work fine on gecko-based browsers, but I'm not sure about Opera
> >>> and IEs.
> >> Don't let the IE bashing crowd know that IE gets something right with
> >> regards to security and Gecko-based/Opera browsers get it wrong. Namely,
> >> that you shouldn't, under any circumstance, be able to set the value of
> >> a file input.

>
> > I do not really set the value. User sets the value, then I run the
> > script to take that value, create a new form in DOM, append new input
> > file field with user-defined value to this new form and submit.

>
> Why? Why not just submit the current form to an IFrame and be finished
> with it? If you want to upload multiple files, then simply create new
> File inputs dynamically and then submit the form.
>
> > I need it to upload the files without refreshing the page. So, my new
> > form is submitting to iframe and user keeps on working with current
> > visible form.
> > Any suggestions, perhaps?

>
> If you want to be able to keep working on the same page, break the form
> into separate forms. Submit the first to the IFrame and it will leave
> them happily working.
>
> --
> Randy
> Chance Favors The Prepared Mind
> comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
> Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


that could be one of the solutions, but if I keep one form, can I
clone the file object, perhaps? Or, is it the only solution to break
the form?
Thanks


Darko 11-07-2007 08:28 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 9:00 pm, VUNETdotUS <vunet...@gmail.com> wrote:
> On Nov 7, 2:24 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
>
>
>
> > VUNETdotUS said the following on 11/7/2007 2:19 PM:

>
> > > On Nov 7, 2:03 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> > >> s0lnic said the following on 11/7/2007 1:30 PM:

>
> > >>> VUNETdotUS wrote:
> > >>>> can I copy input as a DOM object to another form (thus keeping its
> > >>>> value)?
> > >>> Well, you can do something like:
> > >>> var fileField = document.getElementById('file_field_id');
> > >>> var clonedFileField = fileField.cloneNode(true);
> > >>> document.getElementById('some_form').appendChild(c lonedFileField);
> > >>> This should work fine on gecko-based browsers, but I'm not sure about Opera
> > >>> and IEs.
> > >> Don't let the IE bashing crowd know that IE gets something right with
> > >> regards to security and Gecko-based/Opera browsers get it wrong. Namely,
> > >> that you shouldn't, under any circumstance, be able to set the value of
> > >> a file input.

>
> > > I do not really set the value. User sets the value, then I run the
> > > script to take that value, create a new form in DOM, append new input
> > > file field with user-defined value to this new form and submit.

>
> > Why? Why not just submit the current form to an IFrame and be finished
> > with it? If you want to upload multiple files, then simply create new
> > File inputs dynamically and then submit the form.

>
> > > I need it to upload the files without refreshing the page. So, my new
> > > form is submitting to iframe and user keeps on working with current
> > > visible form.
> > > Any suggestions, perhaps?

>
> > If you want to be able to keep working on the same page, break the form
> > into separate forms. Submit the first to the IFrame and it will leave
> > them happily working.

>
> > --
> > Randy
> > Chance Favors The Prepared Mind
> > comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
> > Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

>
> that could be one of the solutions, but if I keep one form, can I
> clone the file object, perhaps? Or, is it the only solution to break
> the form?
> Thanks


Randy Webb used to write some good posts in the past, but with all due
respect breaking the page into iframes sound horrible. As for the
question, if the topic starter only read what he head been told, he
would have noticed that s0lnic gave him the solution above, with code
and everything. And it works. It is no security issue whatsoever,
since you only clone what the client had already filled in, so I don't
see a reason for panic.


VUNETdotUS 11-07-2007 08:40 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 3:28 pm, Darko <darko.maksimo...@gmail.com> wrote:
> On Nov 7, 9:00 pm, VUNETdotUS <vunet...@gmail.com> wrote:
>
>
>
> > On Nov 7, 2:24 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:

>
> > > VUNETdotUS said the following on 11/7/2007 2:19 PM:

>
> > > > On Nov 7, 2:03 pm, Randy Webb <HikksNotAtH...@aol.com> wrote:
> > > >> s0lnic said the following on 11/7/2007 1:30 PM:

>
> > > >>> VUNETdotUS wrote:
> > > >>>> can I copy input as a DOM object to another form (thus keeping its
> > > >>>> value)?
> > > >>> Well, you can do something like:
> > > >>> var fileField = document.getElementById('file_field_id');
> > > >>> var clonedFileField = fileField.cloneNode(true);
> > > >>> document.getElementById('some_form').appendChild(c lonedFileField);
> > > >>> This should work fine on gecko-based browsers, but I'm not sure about Opera
> > > >>> and IEs.
> > > >> Don't let the IE bashing crowd know that IE gets something right with
> > > >> regards to security and Gecko-based/Opera browsers get it wrong. Namely,
> > > >> that you shouldn't, under any circumstance, be able to set the value of
> > > >> a file input.

>
> > > > I do not really set the value. User sets the value, then I run the
> > > > script to take that value, create a new form in DOM, append new input
> > > > file field with user-defined value to this new form and submit.

>
> > > Why? Why not just submit the current form to an IFrame and be finished
> > > with it? If you want to upload multiple files, then simply create new
> > > File inputs dynamically and then submit the form.

>
> > > > I need it to upload the files without refreshing the page. So, my new
> > > > form is submitting to iframe and user keeps on working with current
> > > > visible form.
> > > > Any suggestions, perhaps?

>
> > > If you want to be able to keep working on the same page, break the form
> > > into separate forms. Submit the first to the IFrame and it will leave
> > > them happily working.

>
> > > --
> > > Randy
> > > Chance Favors The Prepared Mind
> > > comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
> > > Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

>
> > that could be one of the solutions, but if I keep one form, can I
> > clone the file object, perhaps? Or, is it the only solution to break
> > the form?
> > Thanks

>
> Randy Webb used to write some good posts in the past, but with all due
> respect breaking the page into iframes sound horrible. As for the
> question, if the topic starter only read what he head been told, he
> would have noticed that s0lnic gave him the solution above, with code
> and everything. And it works. It is no security issue whatsoever,
> since you only clone what the client had already filled in, so I don't
> see a reason for panic.


I do not know how it happened but I never saw a second rely from
s0lnic. cloneNode seems to be not browser compatible, doesn't it? I'll
try to test now...
Thanks.


VUNETdotUS 11-07-2007 09:47 PM

Re: Copy File Field Value to Dynamic File Field Value
 
On Nov 7, 3:40 pm, VUNETdotUS <vunet...@gmail.com> wrote:
> On Nov 7, 3:28 pm, Darko <darko.maksimo...@gmail.com> wrote:


> s0lnic. cloneNode seems to be not browser compatible, doesn't it? I'll
> try to test now...
> Thanks.


Obviously, IE doe snot support. Is anyone familiar with cross browser
idea for cloning?




All times are GMT. The time now is 05:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.