Hi all , In the below code am trying to upload file to a folder and if file is already there it will generatr a messagebox(wn32) where it will ask for overwrite but when i run my rails application on client machine this messagebox is not displaying on client machine require ''dl'' # button constantsBUTTONS_OK = 0 BUTTONS_OKCANCEL = 1 BUTTONS_ABORTRETRYIGNORE = 2 BUTTONS_YESNO = 4 CLICKED_CANCEL = 2 CLICKED_ABORT = 3 CLICKED_RETRY = 4 CLICKED_IGNORE = 5 CLICKED_YES = 6 CLICKED_NO = 7 class UploadController < ApplicationController def index render :file => ''app\views\upload\uploadfile.rhtml'' end def message_box(txt, title=APP_TITLE, buttons=BUTTONS_OK) user32 = DL.dlopen(''user32'') msgbox = user32[''MessageBoxA'', ''ILSSI''] r, rs = msgbox.call(0, txt, title, buttons) return r end def uploadFile name=DataFile.save1(params[:upload]) puts name $t=0 k = [] File.open("d:/dm/aan.txt").each do |line| k << line.chomp end puts k #puts line.size $s=k.size #puts $s for i in 0..Integer($s) if $L=(name.eql?(k[i]) == true) response = message_box("Are you sure you want to OVERWRITE", "Proceed?", BUTTONS_YESNO) if response == CLICKED_YES post = DataFile.save(params[:upload]) render :text => "File has been uploaded successfully" else render :text => "File cann''t successfully" end end end end end How should i make this messagebox appear on client side -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 20 October 2010 14:37, Amit Tomar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi all , > In the below code am trying to upload file to a folder and if > file is already there it will generatr a messagebox(wn32) where it will > ask for overwrite but when i run my rails application on client machine > this messagebox is not displaying on client machine > > > require ''dl'' > # button > constantsBUTTONS_OK = 0 > BUTTONS_OKCANCEL = 1 > BUTTONS_ABORTRETRYIGNORE = 2 > BUTTONS_YESNO = 4 > > CLICKED_CANCEL = 2 > CLICKED_ABORT = 3 > CLICKED_RETRY = 4 > CLICKED_IGNORE = 5 > CLICKED_YES = 6 > CLICKED_NO = 7 > > > > > > class UploadController < ApplicationController > def index > render :file => ''app\views\upload\uploadfile.rhtml'' > end > > > def message_box(txt, title=APP_TITLE, buttons=BUTTONS_OK) > user32 = DL.dlopen(''user32'') > msgbox = user32[''MessageBoxA'', ''ILSSI''] > r, rs = msgbox.call(0, txt, title, buttons) > return r > end > > > > > def uploadFile > > name=DataFile.save1(params[:upload]) > puts name > $t=0 > > k = [] > > File.open("d:/dm/aan.txt").each do |line| > k << line.chomp > end > > puts k > #puts line.size > $s=k.size > #puts $s > > > > for i in 0..Integer($s) > > if $L=(name.eql?(k[i]) == true) > > response = message_box("Are you sure you want to OVERWRITE", > "Proceed?", BUTTONS_YESNO) > if response == CLICKED_YESThis code is in the controller and so runs on the server. There is no way it can appear on the client machine. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #955797:> On 20 October 2010 14:37, Amit Tomar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> BUTTONS_OKCANCEL = 1 >> >> user32 = DL.dlopen(''user32'') >> name=DataFile.save1(params[:upload]) >> #puts line.size >> "Proceed?", BUTTONS_YESNO) >> if response == CLICKED_YES > > This code is in the controller and so runs on the server. There is no > way it can appear on the client machine. > > ColinBut colin is it possible to do something like this using javascript?? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Amit Tomar wrote in post #955979:> Colin Law wrote in post #955797: >> On 20 October 2010 14:37, Amit Tomar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> BUTTONS_OKCANCEL = 1 >>> >>> user32 = DL.dlopen(''user32'') >>> name=DataFile.save1(params[:upload]) >>> #puts line.size >>> "Proceed?", BUTTONS_YESNO) >>> if response == CLICKED_YES >> >> This code is in the controller and so runs on the server. There is no >> way it can appear on the client machine. >> >> Colin > > But colin is it possible to do something like this using javascript??It sure is. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 October 2010 06:48, Amit Tomar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #955797: >> On 20 October 2010 14:37, Amit Tomar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> BUTTONS_OKCANCEL = 1 >>> >>> user32 = DL.dlopen(''user32'') >>> name=DataFile.save1(params[:upload]) >>> #puts line.size >>> "Proceed?", BUTTONS_YESNO) >>> if response == CLICKED_YES >> >> This code is in the controller and so runs on the server. There is no >> way it can appear on the client machine. >> >> Colin > > But colin is it possible to do something like this using javascript??You will have to do the upload as a multi-step operation, maybe using AJAX. For example you could first post just the filename, get the server to check the name and send the result back to the client to display the overwrite question if necessary. Then do the upload if appropriate. You may have to re-check the filename again of course in case another file of that name has been uploaded in the meantime. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.