From: Matthew Margolis Date: 2005-01-30T20:55:34+09:00 Subject: Re: Ruby CGI and blank form fields Please ignore this message. I sent it to the list almost two days ago and for some reason delivery was delayed a day. I have figured out my problem. Thank you, Matthew Margolis Matthew Margolis wrote: > What would be the best way to check if a user enters a value into a form > using ruby cgi? > > I have some code that should only run if the user is uploading a file > but nil tests and key tests don't seem to prevent the code from > executing even if they don't upload anything. > > two things I have tried(that didn't work) can be found below. Perhaps I > am missing something obvious? > > if cgi.has_key?('upload') > #stuff to do if there is an image to upload > end > > unless cgi.params['upload'].first.nil? > #stuff to do if there is an image to upload > end > > > Here is the form itself > -------------------- >
method="post"> > <%imageArray.length.times do |count|%> > >
> Comment: value="<%=commentArray[count]%>"> >
> Number: value="<%=imageArray[count][0..2] %>"> >
> Delete: value="<%=imageArray[count]%>"> >
> <%end%> >
>
> Comment: name="uploadcomment" value=""> > >
> >
> ---------------------------- > > > Thank you, > Matthew Margolis > >