1 2 Previous Next 17 Replies Latest reply: Apr 11, 2012 8:02 AM by indra budiantho RSS

    Upload and download file

    ahmad
      Dears,
      I have this case:

      I have 2 forms, i need in form No. 1 to upload the files into DB.

      and the second form need to download into the PC.

      and the files maybe PDF, CSV, Word.


      Please Help !
        • 1. Re: Upload and download file
          HamidHelal
          What is your form version ? It's hard to difficult solution without knowing form version ...
          • 2. Re: Upload and download file
            Sarah
            hi

            you have to use webutil utilities.
            and if u have fully configured webutil then you can achieve your requirements easily but if its not configured
            then you have to configure webutil first..


            sarah
            • 3. Re: Upload and download file
              ahmad
              I used Forms [32 Bit] Version 10.1.2.0.2
              • 4. Re: Upload and download file
                ahmad
                I have it and fully configured.
                i tried to use WEBUTIL_DOCS (Ready screen), but i faced a problem in saveing file....
                • 5. Re: Upload and download file
                  Sarah
                  hi

                  this is just an example.
                  create table something like this.
                  create table excel (
                  Excel_ID number(10),
                  Excel_Name varchar2(200),
                  excel_file_name blob);
                  
                  
                  
                  and use the following code for downloading.
                  
                  
                  
                  begin
                  if
                       :excel.id is null
                  then
                    message ( 'No Excel file is selected.' );
                    message ( ' ' );
                  return;
                  end if;
                       
                  if                                                          --block   --blob
                       webutil_file_transfer.db_to_client ( 'C:\excel.xls', 'excel', 'image', ' id = ''' || :excel.id || '''' )
                  then
                    client_host ( 'cmd /C start  c:\excel.xls');
                  else
                           message ( 'error' );
                  end if;
                  end;
                  sarah
                  • 6. Re: Upload and download file
                    ahmad
                    Thanks sara,
                    may you explain to me how to upload file first and save it in db ?
                    and then i need to download it.
                    • 7. Re: Upload and download file
                      ahmad
                      I used this example in this link:

                      http://sheikyerbouti.developpez.com/webutil-docs/Webutil_store_edit_docs.htm

                      For browsing, and it works well:
                      Declare
                           LC$Fichier Varchar2(128 ) ;
                      Begin
                           
                        LC$Fichier := PKG_FICHIERS.Selection ;
                        
                        If LC$Fichier is not null Then
                          :TRANSFERTS.FIC_SOURCE := LC$Fichier ;
                        End if ;
                      
                      End ;
                      and to save file:
                      Declare
                          Ln$But     Pls_Integer ;
                          Lb$Res     Boolean ;
                          Lc$Name    Varchar2(128) ;
                          Lc$Sep     Varchar2(1) ;
                      Begin
                        
                        If  :Transferts.Fic_Source Is Not Null 
                        And :Transferts.Nom_Table Is Not Null
                        And :Transferts.Nom_Colonne Is Not Null 
                        And :Transferts.Clause_Where Is Not Null  
                        Then
                         
                        If Upper(:Transferts.Nom_Table) = 'BIN_DOCS' Then
                             Lc$Sep := Webutil_File.Get_File_Separator ; -- 10G
                             If Instr( :Transferts.Fic_Source, Lc$Sep ) > 0 Then
                                Lc$Name := Substr( :Transferts.Fic_Source, Instr( :Transferts.Fic_Source, Lc$Sep, -1 ) + 1, 128 ) ;
                             Else
                                   Lc$Name := :Transferts.Fic_Source ;
                             End If ;
                        End If ;   
                         
                         -- Insert A New Line In Bin_Docs Table --
                         Ln$But := To_Number( Substr( :Transferts.Clause_Where, Instr( :Transferts.Clause_Where, '=' ) + 1, 200 ) ) ;
                         Begin
                           Select 1 Into Ln$But From Bin_Docs Where Doc_Id = Ln$But ;
                         Exception
                              When No_Data_Found Then
                                 Insert Into Bin_Docs ( Doc_Id, Name ) Values ( Ln$But, Lc$Name ) ;
                         End ;
                         
                         
                         If :Transferts.Cb_Progress = 'N' Then
                             
                                 If Not Pkg_Transferts.Client_To_Db
                                 (
                                   :Transferts.Fic_Source,
                                   :Transferts.Nom_Table,
                                   :Transferts.Nom_Colonne,
                                   :Transferts.Clause_Where
                                 ) Then           
                                            
                                   Set_Alert_Property( 'AL_ERROR', Title, 'Client to DB' ) ;
                                   Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'Error when transfering ' 
                                                       || :Transferts.Fic_Source ) ;
                                   Ln$But := Show_Alert( 'AL_ERROR' ) ;
                              
                                 Else
                                      Commit ;
                                      Clear_Message ;
                                      Message('File stored in the database', Acknowledge ) ;        
                                 End If ;
                      
                         Else
                             
                                 If Not Pkg_Transferts.Client_To_Db_With_Progress
                                 (   
                                   :Transferts.Fic_Source,
                                   :Transferts.Nom_Table,
                                   :Transferts.Nom_Colonne,
                                   :Transferts.Clause_Where,
                                       'Transfert Client -> BD',
                                       '>> ' || :Transferts.Fic_Source
                                 ) Then
                                 
                                   Set_Alert_Property( 'AL_ERROR', Title, 'Client to DB' ) ;
                                   Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'Error when transfering ' 
                                                       || :Transferts.Fic_Source ) ;
                                   Ln$But := Show_Alert( 'AL_ERROR' ) ;
                              
                                 Else
                                      Commit ;
                                      Clear_Message ;
                                      Message('File stored in the database', Acknowledge ) ;        
                                 End If ;
                             
                         End If ;
                         
                        Else
                              Set_Alert_Property( 'AL_ERROR', Title, 'DB vers Client' ) ;
                           Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'A source file name must be entered ' ) ;
                           Ln$But := Show_Alert( 'AL_ERROR' ) ;     
                        End If ;
                        
                        Clear_Record ;
                        Go_Block( 'BIN_DOCS' ) ;
                        Execute_Query ;
                      
                      Exception
                            When Others Then
                            Message(Dbms_Error_Text, Acknowledge);
                            
                      End ;
                      but i always come on:
                                   If Not Pkg_Transferts.Client_To_Db
                                 (
                                   :Transferts.Fic_Source,
                                   :Transferts.Nom_Table,
                                   :Transferts.Nom_Colonne,
                                   :Transferts.Clause_Where
                                 ) Then           
                                            
                                   Set_Alert_Property( 'AL_ERROR', Title, 'Client to DB' ) ;
                                   Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'Error when transfering ' 
                                                       || :Transferts.Fic_Source ) ;
                                   Ln$But := Show_Alert( 'AL_ERROR' ) ;
                      why ?

                      Edited by: ahmad on Apr 8, 2012 5:59 AM

                      Edited by: ahmad on Apr 8, 2012 6:01 AM
                      • 8. Re: Upload and download file
                        Sarah
                        hi

                        did you modify webutil.cfg file to set db transfer to true..?
                        for uploading.
                        CLIENT_GET_FILE_NAME();
                        sarah

                        Edited by: Sarah on Apr 8, 2012 6:35 AM
                        • 9. Re: Upload and download file
                          ahmad
                          Thank you sara, i changed this and works well

                          Edited by: ahmad on Apr 8, 2012 6:38 AM
                          • 10. Re: Upload and download file
                            Sarah
                            hi

                            the following should be set to TRUE.
                            transfer.database.enabled=FALSE
                            transfer.appsrv.enabled=FALSE
                            set to "TRUE".
                            transfer.database.enabled=TRUE
                            transfer.appsrv.enabled=TRUE
                            sarah
                            • 11. Re: Upload and download file
                              ahmad
                              ya, sorry i was post test file.
                              Thank you it woooorks well
                              • 12. Re: Upload and download file
                                Sarah
                                and for uploading..
                                plz check out the following link.


                                Re: Open PDF/Word file

                                sarah
                                • 13. Re: Upload and download file
                                  ahmad
                                  Dears,

                                  I have this code to store files in db:
                                  Declare
                                      Ln$But     Pls_Integer ;
                                      Lb$Res     Boolean ;
                                      Lc$Name    Varchar2(128) ;
                                      Lc$Sep     Varchar2(1) ;
                                  Begin
                                    
                                    If  :Transferts.Fic_Source Is Not Null 
                                    And :Transferts.Nom_Table Is Not Null
                                    And :Transferts.Nom_Colonne Is Not Null 
                                    And :Transferts.Clause_Where Is Not Null  
                                    Then
                                     
                                    If Upper(:Transferts.Nom_Table) = 'BIN_DOCS' Then
                                         Lc$Sep := Webutil_File.Get_File_Separator ; -- 10G
                                         If Instr( :Transferts.Fic_Source, Lc$Sep ) > 0 Then
                                            Lc$Name := Substr( :Transferts.Fic_Source, Instr( :Transferts.Fic_Source, Lc$Sep, -1 ) + 1, 128 ) ;
                                         Else
                                               Lc$Name := :Transferts.Fic_Source ;
                                         End If ;
                                    End If ;   
                                     
                                     -- Insert A New Line In Bin_Docs Table --
                                     Ln$But := To_Number(Substr(:Transferts.Clause_Where, Instr(:Transferts.Clause_Where, '=' ) + 1, 200));
                                  
                                     Begin
                                       Select 1 
                                         Into Ln$But 
                                         From Bin_Docs 
                                        Where Doc_Id    = Ln$But
                                          And Ticket_No = :Blk_1.Ticket_No;
                                     Exception
                                          When No_Data_Found Then
                                             Insert Into Bin_Docs (Doc_Id, Name, Ticket_No) Values ( Ln$But, Lc$Name, :Blk_1.Ticket_No);
                                     End ;
                                     
                                     
                                     If :Transferts.Cb_Progress = 'N' Then
                                         
                                             If Not Pkg_Transferts.Client_To_Db
                                             (
                                               :Transferts.Fic_Source,
                                               :Transferts.Nom_Table,
                                               :Transferts.Nom_Colonne,
                                               :Transferts.Clause_Where
                                             ) Then           
                                                        
                                               Set_Alert_Property( 'AL_ERROR', Title, 'Client to DB' ) ;
                                               Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'Error when transfering ' 
                                                                   || :Transferts.Fic_Source ) ;
                                               Ln$But := Show_Alert( 'AL_ERROR' ) ;
                                          
                                             Else                
                                                  Commit ;
                                                  Clear_Message ;
                                                  Message('Êã ÍÝÙ ÇáãáÝ Ýí ÞÇÚÏÉ ÇáÈíÇäÇÊ ÈäÌÇÍ', Acknowledge);
                                                  Message(' ');         
                                             End If ;
                                  
                                     Else
                                         
                                             If Not Pkg_Transferts.Client_To_Db_With_Progress
                                             (   
                                               :Transferts.Fic_Source,
                                               :Transferts.Nom_Table,
                                               :Transferts.Nom_Colonne,
                                               :Transferts.Clause_Where,
                                                   'Transfert Client -> BD',
                                                   '>> ' || :Transferts.Fic_Source
                                             ) Then
                                             
                                               Set_Alert_Property( 'AL_ERROR', Title, 'Client to DB' ) ;
                                               Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'Error when transfering ' 
                                                                   || :Transferts.Fic_Source ) ;
                                               Ln$But := Show_Alert( 'AL_ERROR' ) ;
                                          
                                             Else
                                                  Commit ;
                                                  Clear_Message ;
                                                  Message('File stored in the database', Acknowledge ) ;        
                                             End If ;
                                         
                                     End If ;
                                     
                                    Else
                                          Set_Alert_Property( 'AL_ERROR', Title, 'DB vers Client' ) ;
                                       Set_Alert_Property( 'AL_ERROR', Alert_Message_Text, 'A source file name must be entered ' ) ;
                                       Ln$But := Show_Alert( 'AL_ERROR' ) ;     
                                    End If ;
                                    
                                    Clear_Record ;
                                    Go_Block( 'BIN_DOCS' ) ;
                                    Execute_Query ;
                                  
                                  Exception
                                        When Others Then
                                        Message(Dbms_Error_Text, Acknowledge);
                                        
                                  End ;
                                  and i added new field on the table (Ticket_No), and its a primary key with Doc_Id (Serially).
                                  I need Doc_Id depend on Ticket_No for example:
                                  Ticket_No                      Doc_Id
                                  1                                   1
                                  1                                   2
                                  2                                   1
                                  2                                   2
                                  2                                   3
                                  This line create the serial:
                                  Ln$But := To_Number(Substr(:Transferts.Clause_Where, Instr(:Transferts.Clause_Where, '=' ) + 1, 200));
                                  how can i write a condition where Ticket_No = :Blk_1.Ticket_No ?


                                  Edited by: ahmad on Apr 10, 2012 1:15 AM

                                  Edited by: ahmad on Apr 10, 2012 1:16 AM
                                  • 14. Re: Upload and download file
                                    Zafar Iqbal
                                    Hi Sarah,

                                    please i want to know how to completely configure the "webutil" utility on my application server and developer

                                    I shall be very thanks full to you all :)

                                    my forms version is
                                    Forms [32 Bit] Version 10.1.2.0.2 (Production)

                                    Regards,

                                    Zafar Iqbal
                                    1 2 Previous Next