<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: form code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 21:13:07 GMT</pubDate>
    <description>DZone Snippets: form code</description>
    <item>
      <title>A simple XHTML submit form for ProjectX</title>
      <link>http://snippets.dzone.com/posts/show/5354</link>
      <description>Preparing ProjectX API requests through the browser's address bar  can get quite messy, however inputting the request through a simple form makes it much easier to read.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"&lt;br /&gt;  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;br /&gt;  &lt;head&gt;&lt;br /&gt;    &lt;title&gt;ProjectX API&lt;/title&gt;&lt;br /&gt;    &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"/&gt;&lt;br /&gt;  &lt;/head&gt;&lt;br /&gt;  &lt;body&gt;&lt;br /&gt;    &lt;h1&gt;ProjectX API form&lt;/h1&gt;&lt;br /&gt;    &lt;p&gt;Enter the Project API XML to send a request to the server.&lt;/p&gt;&lt;br /&gt;    &lt;form action="http://rorbuilder.info/api/projectx.cgi" method="post" id="projectx_form"&gt;&lt;br /&gt;    &lt;fieldset&gt;&lt;legend&gt;xml_project&lt;/legend&gt;&lt;textarea id="xml_project" name="xml_project" cols="104" rows="20"&gt;&lt;/textarea&gt;&lt;/fieldset&gt;&lt;br /&gt;    &lt;div&gt;&lt;button type="submit"&gt;Submit&lt;/button&gt;&lt;/div&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;  &lt;p&gt;&lt;br /&gt;    &lt;a href="http://validator.w3.org/check?uri=referer"&gt;&lt;img&lt;br /&gt;        src="http://www.w3.org/Icons/valid-xhtml10"&lt;br /&gt;        alt="Valid XHTML 1.0 Strict" height="31" width="88" style="float:right;  border:0 "/&gt;&lt;/a&gt;&lt;br /&gt;  &lt;/p&gt;&lt;br /&gt;  &lt;p style="clear:float"&gt;last updated: 13th April 2008&lt;/p&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The web page can be seen at http://rorbuilder.info/r/projectx-api/index.html&lt;br /&gt;The following XML request value when submitted should return an XML result containing the results and the method executed.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;project name='whiteboardqueue'&gt;&lt;br /&gt;  &lt;methods&gt;&lt;br /&gt;    &lt;method name='get_user_id'&gt;&lt;br /&gt;      &lt;params/&gt;&lt;br /&gt;    &lt;/method&gt;&lt;br /&gt;  &lt;/methods&gt;&lt;br /&gt;&lt;/project&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;eg.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;result method="rtn_get_user_id"&gt;&lt;br /&gt;  &lt;get_user_id&gt;36539&lt;/get_user_id&gt;&lt;br /&gt;&lt;/result&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 13 Apr 2008 22:32:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5354</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Upload a file using Ajax</title>
      <link>http://snippets.dzone.com/posts/show/5166</link>
      <description>This code is categorised as Ajax because it "fits within my definition of Ajax" as explained from the &lt;a href="http://www.openjs.com/articles/ajax/ajax_file_upload/"&gt;Ajax File Upload&lt;/a&gt; [openjs.com] article.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"&lt;br /&gt;  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;br /&gt;  &lt;head&gt;&lt;br /&gt;    &lt;title&gt;File upload&lt;/title&gt;&lt;br /&gt;    &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"/&gt;&lt;br /&gt;    &lt;script type="text/javascript"&gt;&lt;br /&gt;    //&lt;![CDATA[&lt;br /&gt;      function init() {&lt;br /&gt;	document.getElementById('file_upload_form').onsubmit=function() {&lt;br /&gt;                                  //'upload_target' is the name of the iframe&lt;br /&gt;	  document.getElementById('file_upload_form').target = 'upload_target'; &lt;br /&gt;	  }&lt;br /&gt;  }&lt;br /&gt;  window.onload=init;&lt;br /&gt;    //]]&gt;&lt;br /&gt;    &lt;/script&gt;&lt;br /&gt;  &lt;/head&gt;&lt;br /&gt;  &lt;body&gt;&lt;br /&gt;    &lt;form id="file_upload_form" method="post" enctype="multipart/form-data" action="/p/file_upload.cgi"&gt;&lt;br /&gt;    &lt;input name="myfile" id="myfile" size="27" type="file" /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;input type="submit" name="action" value="Upload" /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;iframe id="upload_target" name="upload_target" src="" style="width:0;height:0;border:0px solid #fff;"&gt;&lt;/iframe&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;  &lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 23 Feb 2008 14:33:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5166</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Upload a file using Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5165</link>
      <description>The following code was used to upload an image file to the web server. Source code origin: &lt;a href="http://www.zytrax.com/tech/lang/ruby/#upload"&gt;Ruby Language Stuff | mod_ruby File upload scripts&lt;/a&gt; [zytrax.com]&lt;br /&gt;&lt;br /&gt;file: file_upload.cgi&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;# ruby script fragment&lt;br /&gt;require 'cgi'&lt;br /&gt;require 'stringio'&lt;br /&gt;&lt;br /&gt;cgi = CGI.new()  # New CGI object&lt;br /&gt;puts "Content-Type: text/plain"&lt;br /&gt;puts&lt;br /&gt;print '&lt;result&gt;'&lt;br /&gt;&lt;br /&gt;# get uri of tx'd file (in tmp normally)&lt;br /&gt;tmpfile = cgi.params['myfile'].first.path&lt;br /&gt;&lt;br /&gt;# OR (functionally the same)&lt;br /&gt;tmpfile = cgi.params['myfile'][0].path&lt;br /&gt;&lt;br /&gt;# create a Tempfile reference&lt;br /&gt;fromfile = cgi.params['myfile'].first&lt;br /&gt;&lt;br /&gt;#displays the original file name as supplied in the form&lt;br /&gt;puts fromfile.original_filename&lt;br /&gt;&lt;br /&gt;# displays the content (mime) type e.g. text/html&lt;br /&gt;puts fromfile.content_type&lt;br /&gt;&lt;br /&gt;# create output file reference as original filename in our chosen directory&lt;br /&gt;tofile = '/var/www/yourdomain.com/htdocs/r/'+fromfile.original_filename&lt;br /&gt;&lt;br /&gt;# copy the file&lt;br /&gt;# note the untaint prevents a security error&lt;br /&gt;# cgi sets up an StringIO object if file &lt; 10240&lt;br /&gt;# or a Tempfile object following works for both&lt;br /&gt;File.open(tofile.untaint, 'w') { |file| file &lt;&lt; fromfile.read}&lt;br /&gt;# when the page finishes the Tempfile/StringIO!) thing is deleted automatically&lt;br /&gt;&lt;br /&gt;print '&lt;/result&gt;'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;file: file_upload.html&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"&lt;br /&gt;  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;br /&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;&lt;br /&gt;  &lt;head&gt;&lt;br /&gt;    &lt;title&gt;File upload&lt;/title&gt;&lt;br /&gt;    &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"/&gt;&lt;br /&gt;  &lt;/head&gt;&lt;br /&gt;  &lt;body&gt;&lt;br /&gt;    &lt;form name='fileupload' enctype="multipart/form-data" &lt;br /&gt;    action='/p/file_upload.cgi' method='post'&gt;&lt;br /&gt;    &lt;input type='file' name='myfile' size="40" /&gt;&lt;br /&gt;    &lt;input type='submit' value"Send it"/&gt;&lt;br /&gt;    &lt;/form&gt;&lt;br /&gt;  &lt;/body&gt;&lt;br /&gt;&lt;/html&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 23 Feb 2008 13:26:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5165</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Submit Form programmatically from PHP using JavaScript</title>
      <link>http://snippets.dzone.com/posts/show/5154</link>
      <description>It&#180;s something quite easy but may help a newby (as I&#180;m now) in the future. &lt;br /&gt;This is a simple function in PHP to insert a JavaScript sentence which will do the same action as if the user would be pressing the Submit Button.&lt;br /&gt;It can be used to use any control as a Submit Button or in case you make a form you need to send without interaction from the user.&lt;br /&gt;the $FormName must be the name specified in the Form tag (i.e.: &lt;form action="MyActionURL" method="post" enctype="application/x-www-form-urlencoded" name="MyFormName"&gt;), if you didn&#180;t specified any, you must now :)&lt;br /&gt;Lastly, just a tip regarding a trouble I had and may be you case too... if you have a form with all hidden fields, it won&#180;t work, you have to have at least something echoed inside the form, just a letter can help, anyway, as it will redirect to the action URL, it should not be a problem as the form will disappear.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function SubmitForm($FormName)&lt;br /&gt;//JavaScript function to submit a form programmatically&lt;br /&gt;//$FormName must be form&#180;s name (as specified in the opening form tag)&lt;br /&gt;{&lt;br /&gt;	echo '&lt;script language="javascript"&gt;document.'.$FormName.'.submit()&lt;/script&gt;';&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 19 Feb 2008 20:23:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5154</guid>
      <author>dneuma (Daniel Neumann)</author>
    </item>
    <item>
      <title>'Delete a Twitter entry' dissected</title>
      <link>http://snippets.dzone.com/posts/show/5145</link>
      <description>The following code was copied from my Twitter home page, it shows how to delete a twitter entry on the server.&lt;br /&gt;&lt;br /&gt;raw HTML code with embedded JavaScript code.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="if (confirm('Sure you want to delete this update? There is NO undo!')) &lt;br /&gt;{var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = &lt;br /&gt;'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); &lt;br /&gt;m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var s = &lt;br /&gt;document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); &lt;br /&gt;s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); f.appendChild(s);f.submit(); };return false;" &lt;br /&gt;title="Delete this update?"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;same code as above but with comments.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;a href="/status/destroy/719423092" onclick="&lt;br /&gt;&lt;br /&gt;                     // if the user clicks the 'OK' button the confirm function will return true&lt;br /&gt;if (confirm('Sure you want to delete this update? There is NO undo!')) { &lt;br /&gt;&lt;br /&gt;  // -- dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  var f = document.createElement('form'); // create the dhtml 'form' (&lt;form/&gt;) element&lt;br /&gt;  f.style.display = 'none';               // hide the form&lt;br /&gt;  this.parentNode.appendChild(f);         // append the form element to the parent of the current node (&lt;a/&gt;)&lt;br /&gt;  f.method = 'POST';                      // add the method to the form&lt;br /&gt;  f.action = this.href;                   // add the action using the href of the current node (&lt;a/&gt;)&lt;br /&gt;    &lt;br /&gt;  var m = document.createElement('input');   // create the input (&lt;input/&gt;) 'element' &lt;br /&gt;  m.setAttribute('type', 'hidden');          // set the input type to 'hidden'&lt;br /&gt;  m.setAttribute('name', '_method');         // set the input name to '_method'&lt;br /&gt;  m.setAttribute('value', 'delete');         // set the input value to 'delete'&lt;br /&gt;  f.appendChild(m);                          // append the input element to the form element&lt;br /&gt;  &lt;br /&gt;  var s = document.createElement('input');   // create another input element&lt;br /&gt;  s.setAttribute('type', 'hidden');          // set the type to 'hidden'&lt;br /&gt;  s.setAttribute('name', 'authenticity_token'); // set the name to 'authenticity_token'&lt;br /&gt;  &lt;br /&gt;                                     // set the input element's value using a unique id.&lt;br /&gt;  s.setAttribute('value', 'd0057265c3784d2a6dc6cdb2c26083f638152151'); &lt;br /&gt;  &lt;br /&gt;  f.appendChild(s);                  // apend the input element to the form element&lt;br /&gt;  // -- end of dhtml: creating html elements on-the-fly -------------------------------&lt;br /&gt;  &lt;br /&gt;  f.submit(); // post the form data back to the server to delete the record, &lt;br /&gt;              // just as if the user had pressed the submit button.&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;  return false; // returning false cancels the default &lt;a href="..."&gt; request. &lt;br /&gt;                 // However if JavaScript had been disabled for some reason the &lt;br /&gt;                 // &lt;a href="..."&gt; would have acted normally, meaning the record &lt;br /&gt;                 // would have been deleted from following the URL request directly.&lt;br /&gt; "&lt;br /&gt;&lt;/code&gt; &lt;br /&gt;Note: Twitter needs JavaScript for the web page to work properly, I've tried and it is not possible to delete a record without JavaScript.  The authenticity_token has been altered by me to prevent any malicious activity on my Twitter account.&lt;br /&gt;</description>
      <pubDate>Sat, 16 Feb 2008 13:17:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5145</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Blueprint CSS forms extension</title>
      <link>http://snippets.dzone.com/posts/show/5010</link>
      <description>Changes the widths of form elements so they fit into smaller columns created using the &lt;a href="http://code.google.com/p/blueprintcss/"&gt;Blueprint CSS framework&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;div.span-1 input.text, div.span-1 input.title { width:  30px; }&lt;br /&gt;div.span-2 input.text, div.span-2 input.title { width:  50px; }&lt;br /&gt;div.span-3 input.text, div.span-3 input.title { width:  90px; }&lt;br /&gt;div.span-4 input.text, div.span-4 input.title { width: 130px; }&lt;br /&gt;div.span-5 input.text, div.span-5 input.title { width: 170px; }&lt;br /&gt;div.span-6 input.text, div.span-6 input.title { width: 210px; }&lt;br /&gt;div.span-7 input.text, div.span-7 input.title { width: 250px; }&lt;br /&gt;div.span-8 input.text, div.span-8 input.title { width: 290px; }&lt;br /&gt;&lt;br /&gt;div.span-1 select { width:  30px; }&lt;br /&gt;div.span-2 select { width:  50px; }&lt;br /&gt;div.span-3 select { width:  90px; }&lt;br /&gt;div.span-4 select { width: 130px; }&lt;br /&gt;div.span-5 select { width: 170px; }&lt;br /&gt;&lt;br /&gt;div.span-1  textarea { width:  30px; height:  25px; }&lt;br /&gt;div.span-2  textarea { width:  50px; height:  50px; }&lt;br /&gt;div.span-3  textarea { width:  90px; height:  75px; }&lt;br /&gt;div.span-4  textarea { width: 130px; height: 100px; }&lt;br /&gt;div.span-5  textarea { width: 170px; height: 125px; }&lt;br /&gt;div.span-6  textarea { width: 210px; height: 150px; }&lt;br /&gt;div.span-7  textarea { width: 250px; height: 175px; }&lt;br /&gt;div.span-8  textarea { width: 290px; height: 200px; }&lt;br /&gt;div.span-9  textarea { width: 330px; height: 225px; }&lt;br /&gt;div.span-10 textarea { width: 370px; height: 250px; }&lt;/code&gt;</description>
      <pubDate>Sat, 19 Jan 2008 17:00:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5010</guid>
      <author>sporkyy (Todd Sayre)</author>
    </item>
    <item>
      <title>Use rails date_select without activerecord model</title>
      <link>http://snippets.dzone.com/posts/show/4630</link>
      <description>// In your view:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;%= date_select('range', 'start_date', :order =&gt; [:month, :day, :year])%&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;// In your controller:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Credit: http://www.jonsthoughtsoneverything.com/2006/05/21/how-to-access-date_select-without-an-active-record-model/</description>
      <pubDate>Wed, 10 Oct 2007 12:42:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4630</guid>
      <author>davenolan (davenolan)</author>
    </item>
    <item>
      <title>text input /w background image</title>
      <link>http://snippets.dzone.com/posts/show/4444</link>
      <description>// self-explanatory. see title.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.searchBox{&lt;br /&gt;  background-image:url('http://www.dhtmlgoodies.com/tips-and-tricks/input-with-background/images/magnifying-glass.gif');&lt;br /&gt;  background-repeat:no-repeat;&lt;br /&gt;  padding-left:20px;&lt;br /&gt;}&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;input type="text" name="search" style="border:2px inset gray;color:black;background-color:lightyellow;font-family:arial narrow;font-weight:bold;font-size:9pt;" class="searchBox"&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 22 Aug 2007 14:43:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4444</guid>
      <author>thescriptkeeper (mona)</author>
    </item>
    <item>
      <title>Using a mutiple collection select form helper with habtm or has many associations in Rails</title>
      <link>http://snippets.dzone.com/posts/show/4369</link>
      <description>// where user has and belongs to many roles&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# in your view&lt;br /&gt;&lt;%= collection_select :user, :role_ids, Role.find(:all, :order =&gt; 'name ASC'), :id, :name, { :selected =&gt; @user.role_ids }, { :multiple =&gt; true, :name =&gt; 'user[role_ids][]' } -%&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 30 Jul 2007 08:58:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4369</guid>
      <author>davenolan (davenolan)</author>
    </item>
    <item>
      <title>Fix for camping multipart parsing issue.</title>
      <link>http://snippets.dzone.com/posts/show/4356</link>
      <description>// description of your code here&lt;br /&gt;I wrote a nice description of this issue, but snippets ate it.  &lt;br /&gt;&lt;br /&gt;In short, this parses complicated form names into nice hashes, i.e. name[asd][asd] for multipart forms.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;module Camping&lt;br /&gt;module Base&lt;br /&gt; def initialize(r, e, m) #:nodoc:&lt;br /&gt;      e = H[e.to_hash]&lt;br /&gt;      @status, @method, @env, @headers, @root = 200, m.downcase, e,&lt;br /&gt;          {'Content-Type'=&gt;'text/html'}, e.SCRIPT_NAME.sub(/\/$/,'')&lt;br /&gt;      @k = C.kp(e.HTTP_COOKIE)&lt;br /&gt;      qs = C.qs_parse(e.QUERY_STRING)&lt;br /&gt;      @in = r&lt;br /&gt;      todo = []&lt;br /&gt;      if %r|\Amultipart/form-data.*boundary=\"?([^\";,]+)|n.match(e.CONTENT_TYPE)&lt;br /&gt;        b = /(?:\r?\n|\A)#{Regexp::quote("--#$1")}(?:--)?\r$/&lt;br /&gt;        until @in.eof?&lt;br /&gt;          fh=H[]&lt;br /&gt;          for l in @in&lt;br /&gt;            case l&lt;br /&gt;            when Z: break&lt;br /&gt;            when /^Content-Disposition: form-data;/&lt;br /&gt;              fh.u H[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten]&lt;br /&gt;            when /^Content-Type: (.+?)(\r$|\Z)/m&lt;br /&gt;              puts "=&gt; fh[type] = #$1"&lt;br /&gt;              fh[:type] = $1&lt;br /&gt;            end&lt;br /&gt;          end&lt;br /&gt;          fn=fh[:name]&lt;br /&gt;          o=if fh[:filename]&lt;br /&gt;            o=fh[:tempfile]=Tempfile.new(:C)&lt;br /&gt;            o.binmode&lt;br /&gt;          else&lt;br /&gt;            fh=""&lt;br /&gt;          end&lt;br /&gt;          while l=@in.read(16384)&lt;br /&gt;            if l=~b&lt;br /&gt;              o&lt;&lt;$`.chomp&lt;br /&gt;              @in.seek(-$'.size,IO::SEEK_CUR)&lt;br /&gt;              break&lt;br /&gt;            end&lt;br /&gt;            o&lt;&lt; l&lt;br /&gt;          end&lt;br /&gt;          if(fn)&lt;br /&gt;            qs.merge!(C.qs_parse(fn + "=1"))&lt;br /&gt;            parts = fn.split(/\[/)&lt;br /&gt;            line = ""&lt;br /&gt;            parts.each do |pp|&lt;br /&gt;              pp = pp.gsub(/\]/,"")&lt;br /&gt;              line += "['#{pp}']"&lt;br /&gt;            end&lt;br /&gt;            #p "line is:"&lt;br /&gt;            #p line&lt;br /&gt;            #p fh&lt;br /&gt;            todo &lt;&lt; ["qs#{line}", fh]&lt;br /&gt;            #eval("qs#{line} = fh")&lt;br /&gt;            #p qs&lt;br /&gt;          end&lt;br /&gt;          fh[:tempfile].rewind if fh.is_a?H&lt;br /&gt;        end&lt;br /&gt;      elsif @method == "post"&lt;br /&gt;        qs.merge!(C.qs_parse(@in.read))&lt;br /&gt;      end&lt;br /&gt;      #post process vars&lt;br /&gt;      todo.each do |n|&lt;br /&gt;        eval("#{n.first} = n.last")&lt;br /&gt;      end&lt;br /&gt;      #p "END QUERY"&lt;br /&gt;      #p qs&lt;br /&gt;      #exit&lt;br /&gt;      @cookies, @input = @k.dup, qs.dup&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;end &lt;br /&gt;end&lt;br /&gt;// insert code here..&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 26 Jul 2007 01:53:58 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4356</guid>
      <author>NetherBen (Ben)</author>
    </item>
  </channel>
</rss>
