Il Neofita wrote:> <script type="text/javascript" language="JavaScript"> > function invia() > { > var url = ''/test/''; > var params = ''file='' + $F(''fi''); > alert(params); > > return false; > } > </script> > </head> > <body> > <form onsubmit="invia();" method=post> > <input type="file" id="fi" /> > <input type=submit> > </form> > </body> > </html> > > Everytime I receive file=undefine. I would like to have the name of the fileYou can''t. It''s a JS security issue. Browsers do not let you have access to the contents or name of the file chosen via a file input. The best you can do is wait for the user to submit it to the server(Prototype can''t serialize a file input either) and then make an Ajax request to get it back. -- Michael Peters Developer Plus Three, LP
<script type="text/javascript" language="JavaScript"> function invia() { var url = ''/test/''; var params = ''file='' + $F(''fi''); alert(params); return false; } </script> </head> <body> <form onsubmit="invia();" method=post> <input type="file" id="fi" /> <input type=submit> </form> </body> </html> Everytime I receive file=undefine. I would like to have the name of the file _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
oh really? try this.. <input type="file" id="fi" onchange="alert($(''fi'').value)" /> ;) tell me JS won''t let you receive the value of a file input now, one thing js won''t let you do is set the value of the file input -Jaimz Michael Peters wrote:> Il Neofita wrote: > >> <script type="text/javascript" language="JavaScript"> >> function invia() >> { >> var url = ''/test/''; >> var params = ''file='' + $F(''fi''); >> alert(params); >> >> return false; >> } >> </script> >> </head> >> <body> >> <form onsubmit="invia();" method=post> >> <input type="file" id="fi" /> >> <input type=submit> >> </form> >> </body> >> </html> >> >> Everytime I receive file=undefine. I would like to have the name of the file >> > > You can''t. It''s a JS security issue. Browsers do not let you have access to the > contents or name of the file chosen via a file input. The best you can do is > wait for the user to submit it to the server(Prototype can''t serialize a file > input either) and then make an Ajax request to get it back. > >